Hi,
First post, so go easy and all that !
I am developing a COM addin that is essentially a port of an .xlam. The .xlam created two new sheets in the active workbook and all was fine and dandy.
This is not the case with the COM addin. Below is the connection code (for testing purposes). Adding a sheet to the active workbook of the 'connecting Excel application instance' fails but is fine if we create a new workbook - we can then add sheets to our hearts content. I am using VB6 btw:
Anyideas would be useful. The idea is that settings are stored in the new sheets and hidden and then the workbook can be sent ot other with the addin and used etc...
Thanks in advance,
Steve.
First post, so go easy and all that !
I am developing a COM addin that is essentially a port of an .xlam. The .xlam created two new sheets in the active workbook and all was fine and dandy.
This is not the case with the COM addin. Below is the connection code (for testing purposes). Adding a sheet to the active workbook of the 'connecting Excel application instance' fails but is fine if we create a new workbook - we can then add sheets to our hearts content. I am using VB6 btw:
Code:
Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
Set xl = Application
'****************************************************
'DOES NOT WORK, throws a '1004 error - method ~ of object ~ failed'
Dim AWB As Excel.Workbook
Set AWB = xl.ActiveWorkbook
AWB.Sheets.Add After:=AWB.Sheets.Count
oXL.ActiveSheet.Name = "Blah Blah"
'****************************************************
' DOES WORK
' Dim AWB As Excel.Workbook
' Set AWB = xl.Workbooks.Add
'
'With xl.ActiveWorkbook
'
' MsgBox "About to add a sheet to the new workbook"
' .Sheets.Add
' .ActiveSheet.Name = "Blah blah blah"
'
'End With
Anyideas would be useful. The idea is that settings are stored in the new sheets and hidden and then the workbook can be sent ot other with the addin and used etc...
Thanks in advance,
Steve.
Last edited: