Information générale
Catégorie:
COM/DCOM et OLE Automation
Titre:
Can't run Excel macro
I have a macro that i have saved into my "Personal Macros Folder" - which excel saves in a personal.xls file. The file and macro are:
C:\windows\application data\microsoft\excel\xlstart\personal.xls!FormatDisp
I need to open up approx 85 spreadsheets and run this macro. When i run this macro after manually starting excel and opening one of the spreadsheets, the macro runs fine. If i run the following code:
oExcel = CREATEOBJECT("Excel.Application")
oExcel.Visible = .T.
oWorkbook = oExcel.Workbooks.Open(fName)
oWorkbook.Application.Visible = .T.
oWorkbook.Windows[1].Activate()
oExcel.Application.Run("C:\Windows\Application Data\Microsoft\Excel\XLSTART\Personal.XLS!FormatDisp")
I get a msg that the macro does not exist. But it does. The msg is:
OLE Idispatch exception code the macro C:\Windows\Application Data\Microsoft\Excel\XLSTART\Personal.XLS!FormatDisp cannot be found.
I have checked the spelling of the file and the macro name several times and they are correct.
Any ideas?
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement