Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, August 30, 2010 12:34 PM
I am automating excel via Python and the win32 COM interface. Upon launching Excel and then opening a workbook, I notice that all of the addins which usually load when Excel is launched normally (double-clicking via Windows Explorer) are not loaded. How can I automate Excel, or launch Excel, via the COM interface and force the addins to load correctly?
All replies (6)
Tuesday, August 31, 2010 4:26 PM ✅Answered
Hi newbie
OK. Cross referencing your code with
http://mail.python.org/pipermail/python-win32/2003-December/001445.html
tells me that this is basically CreateObject in the "COM VB world" (vs. Dispatch which is the equivalent of GetObject).
So the next question would be if there's something on this particular machine configuration or something in the way Python "hooks into" CreateObject that is causing Excel to go into some kind of safe or secure mode.
I should have thought to ask you which version of Excel you're using, but I didn't so I have to ask now :-)
Also, are the add-ins that aren't loading Excel add-ins or COM Add-ins? And are you able to see/load these add-ins as an end-user, once Excel has been launched?
Cindy Meister, VSTO/Word MVP
Tuesday, August 31, 2010 5:22 PM ✅Answered
Newbie et al,
I thought I would join You here and clear some mud:
1. By default no add-ins are loaded when automating Excel. The only exception, which Bessie Zhao also points out, is when automating from the .NET platform.
2. So when using Phyton the question is how to load the wanted add-in(s). Because this is a VBA/VB6/VB.NET forum we usually lack knowledge for languages like Phyton.
But we can always provide You with an answer in VBA and Your challenge is simple to convert it to Phyton ;-)
To load a native add-in (file extension xla or xlam) the easiest way is as the following example shows:
Sub Load_AddIn()
Dim myAddin As String
myAddin = "C:\Users\Dennis Wallentin\Documents\myXLA.xla"
Application.Workbooks.Open (myAddin)
End Sub
Let us know if this is workable for You or not.
Kind regards, Dennis (http://xldennis.wordpress.com/)
Monday, August 30, 2010 2:12 PM
Hi newbie
Could you provide more information about how this is done with Python? Most folks here use MS software, understandably, so it's not "obvious" to us what path you're following to launch Excel...
Cindy Meister, VSTO/Word MVP
Monday, August 30, 2010 6:43 PM
My code to do this is quite simple - I hope this helps to clarify what I am doing. I create an instance of Excel via win32com and then manipulate it using the COM interface that Excel provides.
from win32com.client import DispatchEx
fname = xl_file
xl = DispatchEx("Excel.Application")
xl.Workbooks.Open(fname)
xl.Visible = True
xl.Application.Run("StoreParams")
Tuesday, August 31, 2010 5:48 AM
Hello Newbie,
As Cindy said above, in this forum, there are few people using Python script language. Actually, I am also not very familiar with this language. However, here is a resource about Automation Excel via Python which might interest you, http://win32com.goermezer.de/content/view/95/192/. How about the result? still not load the add-ins?
Also, I'd like to suggest you use Excel Automation use .Net language. It will load the add-ins automatically. Here is a sample which could help you:
How to automate Microsoft Excel from Microsoft Visual C#.NET:
http://support.microsoft.com/kb/302084.
If you have any concern for this post, just feel free to follow up.
Best regards,
Bessie Zhao - MSFT
MSDN Subscriber Support in Forum
If you have any feedback of our support, please contact [email protected].
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, September 6, 2010 9:34 AM
Hello again Newbie,
I am writing to check the status of the issue on your side. Could you please let me know if the suggestion works for you or not? If you have any questions or concerns, please feel free to let me know, or unmark it again. I will be more than happy to be of assistance.
Best regards,
Bessie Zhao - MSFT
MSDN Subscriber Support in Forum
If you have any feedback of our support, please contact [email protected].
Please remember to mark the replies as answers if they help and unmark them if they provide no help.