![]() |
Installing Addin via Automation
I have an addin that I know functions correctly under normal
circumstances. If I manually add the addin via the excel UI, the application addin installs correctly. However, if I attempt to install the addin via automation, the Workbook_AddinInstall method does not seem to run or at least does not report errors back to the UI. I'm using the following code: Dim oXL Dim oAddin Set oXL = CreateObject("Excel.Application") oXL.Workbooks.Add Set oAddin = oXL.AddIns.Add("C:\Program Files\Company\Product\MacroFiles\Macro.xla") oAddin.Installed = True With this code the macro is automatically added in, but the AddinInstall method clearly never runs or at least errors. For a correct install I need this method to run. Any thoughts on this would be greatly appreciated. |
Installing Addin via Automation
Good evening Aragorn Just a shot in the dark, Aragorn, but the code you're using isn't b any chance saved as an add-in is it (ie, with no worksheet visible)? If it is, then that's the problem. Excel likes to have a workshee visible before it will allow a macro to start tinkering with the add-i settings. But if that's not the case then I don't know I'm afraid... HTH Dominic -- dominic ----------------------------------------------------------------------- dominicb's Profile: http://www.excelforum.com/member.php...fo&userid=1893 View this thread: http://www.excelforum.com/showthread.php?threadid=47955 |
Installing Addin via Automation
dominicb,
I'm not quite sure what you mean, so I'll describe to you how I have it set up. The vba project is saved as a .xla file. This xla contains a VBA macro project with Sheet1, Sheet2, Sheet3, and ThisWorkBook as objects. ThisWorkbook implements Sub Workbook_AddinInstall() The method adds several menu options and definitely runs when I manual select it in excel. The script below never seems to result in the AddinInstall method being run. I'm assuming that you're at least on trace to some degree. I'm very new to all of this, so you're insite is definitely helpful. Thanks. dominicb wrote: Good evening Aragorn Just a shot in the dark, Aragorn, but the code you're using isn't by any chance saved as an add-in is it (ie, with no worksheet visible)? If it is, then that's the problem. Excel likes to have a worksheet visible before it will allow a macro to start tinkering with the add-in settings. But if that's not the case then I don't know I'm afraid... HTH DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=479551 |
Installing Addin via Automation
For me the AddinInstall event runs with your method.
Do you have any other instance of Excel open when you create your new instance. If so, certain changes will only persist after closing the last instance, and assuming changes were made in that instance. Might be worth testing with GetObject (under On Error Resume Next) before using CreateObject. This alone is not foolproof. Regards, Peter T "Aragorn" wrote in message oups.com... dominicb, I'm not quite sure what you mean, so I'll describe to you how I have it set up. The vba project is saved as a .xla file. This xla contains a VBA macro project with Sheet1, Sheet2, Sheet3, and ThisWorkBook as objects. ThisWorkbook implements Sub Workbook_AddinInstall() The method adds several menu options and definitely runs when I manual select it in excel. The script below never seems to result in the AddinInstall method being run. I'm assuming that you're at least on trace to some degree. I'm very new to all of this, so you're insite is definitely helpful. Thanks. dominicb wrote: Good evening Aragorn Just a shot in the dark, Aragorn, but the code you're using isn't by any chance saved as an add-in is it (ie, with no worksheet visible)? If it is, then that's the problem. Excel likes to have a worksheet visible before it will allow a macro to start tinkering with the add-in settings. But if that's not the case then I don't know I'm afraid... HTH DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=479551 |
Installing Addin via Automation
Peter,
I only expect that instance of excel to be open at install time, but even another instance exists, I think it's reasonable that the user won't expect excel to reflect its changes until excel has to be reloaded in memory. That's all cool and isn't what I'm seeing. How do you know for certain that the AddinInstall event is running. My script does add the addin, it just doesn't add my menu items for me. I'm assuming that you set up some dummy project. If so, can I see it. Aaron Peter T wrote: For me the AddinInstall event runs with your method. Do you have any other instance of Excel open when you create your new instance. If so, certain changes will only persist after closing the last instance, and assuming changes were made in that instance. Might be worth testing with GetObject (under On Error Resume Next) before using CreateObject. This alone is not foolproof. Regards, Peter T "Aragorn" wrote in message oups.com... dominicb, I'm not quite sure what you mean, so I'll describe to you how I have it set up. The vba project is saved as a .xla file. This xla contains a VBA macro project with Sheet1, Sheet2, Sheet3, and ThisWorkBook as objects. ThisWorkbook implements Sub Workbook_AddinInstall() The method adds several menu options and definitely runs when I manual select it in excel. The script below never seems to result in the AddinInstall method being run. I'm assuming that you're at least on trace to some degree. I'm very new to all of this, so you're insite is definitely helpful. Thanks. dominicb wrote: Good evening Aragorn Just a shot in the dark, Aragorn, but the code you're using isn't by any chance saved as an add-in is it (ie, with no worksheet visible)? If it is, then that's the problem. Excel likes to have a worksheet visible before it will allow a macro to start tinkering with the add-in settings. But if that's not the case then I don't know I'm afraid... HTH DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=479551 |
Installing Addin via Automation
Hi Aaron,
I only expect that instance of excel to be open at install time, but even another instance exists, I think it's reasonable that the user won't expect excel to reflect its changes until excel has to be reloaded in memory. That's all cool and isn't what I'm seeing. With two instances, try customizing your toolbar in one then close this customized instance, then close the other one. Re-start Excel, no customized toolbar - right. Similar for various other application settings. How do you know for certain that the AddinInstall event is running. My script does add the addin, it just doesn't add my menu items for me. I'm assuming that you set up some dummy project. If so, can I see it. In the "event of a test addin, I put Debug.? "AddinInstall" In the script (in a Word module) I added oXl.Visible = true Stop looked in the xl's immediate window and there it was! then back in Word I stepped through closing the instance and releasing variables. Regards, Peter T "Aragorn" wrote in message oups.com... Peter, I only expect that instance of excel to be open at install time, but even another instance exists, I think it's reasonable that the user won't expect excel to reflect its changes until excel has to be reloaded in memory. That's all cool and isn't what I'm seeing. How do you know for certain that the AddinInstall event is running. My script does add the addin, it just doesn't add my menu items for me. I'm assuming that you set up some dummy project. If so, can I see it. Aaron Peter T wrote: For me the AddinInstall event runs with your method. Do you have any other instance of Excel open when you create your new instance. If so, certain changes will only persist after closing the last instance, and assuming changes were made in that instance. Might be worth testing with GetObject (under On Error Resume Next) before using CreateObject. This alone is not foolproof. Regards, Peter T "Aragorn" wrote in message oups.com... dominicb, I'm not quite sure what you mean, so I'll describe to you how I have it set up. The vba project is saved as a .xla file. This xla contains a VBA macro project with Sheet1, Sheet2, Sheet3, and ThisWorkBook as objects. ThisWorkbook implements Sub Workbook_AddinInstall() The method adds several menu options and definitely runs when I manual select it in excel. The script below never seems to result in the AddinInstall method being run. I'm assuming that you're at least on trace to some degree. I'm very new to all of this, so you're insite is definitely helpful. Thanks. dominicb wrote: Good evening Aragorn Just a shot in the dark, Aragorn, but the code you're using isn't by any chance saved as an add-in is it (ie, with no worksheet visible)? If it is, then that's the problem. Excel likes to have a worksheet visible before it will allow a macro to start tinkering with the add-in settings. But if that's not the case then I don't know I'm afraid... HTH DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=479551 |
Installing Addin via Automation
Typo -
In the "event of a test addin, I put should read In the AddinInstall event of a test addin, Peter T |
All times are GMT +1. The time now is 04:21 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com