M
Montezuma
Hi all,
i create a new Workbook programmatically from a Word Macro. This
Workbook must have a Addin loaded when it get created.
So, what i want to do is to load the Addin before creating the
Workbook.
This is the my code, in Word:
Dim excelApp As Object
Dim templatePathVariant As Variant
Dim lotusOfficeAddIn As Object
Dim lotusOfficeAddInFilePath As String
Set excelApp = CreateObject("Excel.Application")
templatePathVariant = templatePath
Set newDocument =
excelApp.WorkBooks.Add(Template:=templatePath)
lotusOfficeAddInFilePath = Environ$("appdata") &
"\Microsoft\Excel\XLSTART\LotusOffice.xla"
Set lotusOfficeAddIn =
excelApp.AddIns.Add(lotusOfficeAddInFilePath, True)
excelApp.AddIns(lotusOfficeAddIn.Title).Installed = True
excelApp.Visible = True
The code seems to work fine. The Workbook get created.
What is strange, it's that now, from the Workbook in Excel, i can't
access to the Addin, although the Addin results installed in Excel
(checked through its "Installed" property).
This is the code:
Private Sub Workbook_Open()
Application.Run ("LotusOffice.xla!LotusOffice_onOpen")
End Sub
What i get is a Runtime error 1004: 'LotusOffice.xla' could not be
found. Check the spelling of the file name,
and verify that the file location is correct.
But as i said, the addin with Title "LotusOffice.xla" appears
installed.
Now the weird behaviour.
If i add the addin path to call it, i mean with
Application.Run (Environ$("appdata") & "\Microsoft\Excel\XLSTART\"
& "LotusOffice.xla!LotusOffice_onOpen")
it says that Excel cannot find the macro "LotusOffice_onOpen" (it's
declared Public, in LotusOffice.xla)
But if then i call again (in the same debug session) the line
Application.Run ("LotusOffice.xla!LotusOffice_onOpen")
then Excel finds the macro correctly!!
What is that??
i create a new Workbook programmatically from a Word Macro. This
Workbook must have a Addin loaded when it get created.
So, what i want to do is to load the Addin before creating the
Workbook.
This is the my code, in Word:
Dim excelApp As Object
Dim templatePathVariant As Variant
Dim lotusOfficeAddIn As Object
Dim lotusOfficeAddInFilePath As String
Set excelApp = CreateObject("Excel.Application")
templatePathVariant = templatePath
Set newDocument =
excelApp.WorkBooks.Add(Template:=templatePath)
lotusOfficeAddInFilePath = Environ$("appdata") &
"\Microsoft\Excel\XLSTART\LotusOffice.xla"
Set lotusOfficeAddIn =
excelApp.AddIns.Add(lotusOfficeAddInFilePath, True)
excelApp.AddIns(lotusOfficeAddIn.Title).Installed = True
excelApp.Visible = True
The code seems to work fine. The Workbook get created.
What is strange, it's that now, from the Workbook in Excel, i can't
access to the Addin, although the Addin results installed in Excel
(checked through its "Installed" property).
This is the code:
Private Sub Workbook_Open()
Application.Run ("LotusOffice.xla!LotusOffice_onOpen")
End Sub
What i get is a Runtime error 1004: 'LotusOffice.xla' could not be
found. Check the spelling of the file name,
and verify that the file location is correct.
But as i said, the addin with Title "LotusOffice.xla" appears
installed.
Now the weird behaviour.
If i add the addin path to call it, i mean with
Application.Run (Environ$("appdata") & "\Microsoft\Excel\XLSTART\"
& "LotusOffice.xla!LotusOffice_onOpen")
it says that Excel cannot find the macro "LotusOffice_onOpen" (it's
declared Public, in LotusOffice.xla)
But if then i call again (in the same debug session) the line
Application.Run ("LotusOffice.xla!LotusOffice_onOpen")
then Excel finds the macro correctly!!
What is that??