Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can't run Excel macro
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00544828
Message ID:
00544844
Vues:
9
I found that i had to ALSO open the "personal.xls" file so that excel is "aware" of the macro and i had to change the reference to the macro name that i was running. Instead of the full path/file name, i just had to use the filename!macroname. Something like:

*--- open file to manipulate
oWorkbook = oExcel.Workbooks.Open(fName)

*--- open personal macro file so macros are available
oWorkbook2 = oExcel.Workbooks.Open("C:\Windows\Application Data\Microsoft\Excel\XLSTART\Personal.XLS")

*--- activate the file to manipulate
oWorkbook.Application.Visible = .T.
oWorkbook.Windows[1].Activate()

*--- run the macro
oExcel.Application.Run("Personal.XLS!FormatDisp")




>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?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform