FelixFong Posted May 11, 2007 Posted May 11, 2007 Hi, I am using the Excel UDF to open an Excel file and run some marco. However if I use the open function, the Add-in I need won't be loaded. I checked basically if I use the ObjCreate("Excel.Application") method, Add-in won't be loaded when Excel start. Could you please suggest what can I do to open Excel with Add-in loaded. I tried the shellexecute("excel.exe","","","open" ) method. It works in some PC but not all. And I don't know why it fail. Many thanks
Locodarwin Posted May 12, 2007 Posted May 12, 2007 Here's the basic idea: $sAddIn = "C:\Path\add_in.xla" ; Change this to the filepath of your AddIn $oExcel = ObjCreate("Excel.Application") $oExcel.WorkBooks.Add $oAddIn = $oExcel.AddIns.Add($sAddIn) $oAddIn.Installed = True $oExcel.Quit Run this one time. Now anytime you start Excel, your AddIn will be available. -S (Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]
FelixFong Posted May 15, 2007 Author Posted May 15, 2007 Here's the basic idea: $sAddIn = "C:\Path\add_in.xla" ; Change this to the filepath of your AddIn $oExcel = ObjCreate("Excel.Application") $oExcel.WorkBooks.Add $oAddIn = $oExcel.AddIns.Add($sAddIn) $oAddIn.Installed = True $oExcel.Quit Run this one time. Now anytime you start Excel, your AddIn will be available. -S Hi Locodarwin, thanks for your reply. I tried the following: a.au3 $sAddIn = "H:\prog\essxleqd.xla" $oExcel = ObjCreate("Excel.Application") $oExcel.WorkBooks.Add $oAddIn = $oExcel.AddIns.Add($sAddIn) $oAddIn.Installed = True $oExcel.Quit b.au3 $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 1 $oExcel.WorkBooks.Add $oExcel.WorkBooks.Open("H:\Balance_Inquiry.xls") I ran a.au3 first. Then I run b.au3. However the add-in is not loaded when I run b.au3. Then I try: c.au3 $sAddIn = "H:\prog\essxleqd.xla" $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 1 $oExcel.WorkBooks.Add $oAddIn = $oExcel.AddIns.Add($sAddIn) $oAddIn.Installed = True $oExcel.WorkBooks.Open("H:\Balance_Inquiry.xls") The add-in loaded in this case. However, everytime I run it, it ask me if I want to copy the addin to the Addin directory. If I say yes, then it ask the file is already there, do I want to overwrite it. If I say no, it failed. And this prevent me from automate the process. Any thought? Thanks again.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now