ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vbcsript calls excel macro (https://www.excelbanter.com/excel-programming/361124-vbcsript-calls-excel-macro.html)

vedran

vbcsript calls excel macro
 
Hi,

I have a simple script that should open a workbook, run a macro and save the
file. Everything except the macro part works fine. The file opens and saves
but macro does not run. Can someone please advise me what am I doing wrong.
Below is the script.
Thanks

Dim objExcel
Dim objWorkBook
Set objExcel = CreateObject("EXCEL.APPLICATION")
Set objWorkBook = objExcel.Workbooks.Open("C:\File1.xls")
objExcel.DisplayAlerts=False
objExcel.Run "PERSONAL.xls!FORMAT"
objWorkBook.SaveAs "C:\file2.xls",44
objExcel.DisplayAlerts=True
objWorkBook.Close True
objExcel.Quit
Set objWorkBook = Nothing
Set objExcel = Nothing

Bob Phillips[_14_]

vbcsript calls excel macro
 
Open Personal.xls as well, it is not opened when running Excel in
automation.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"vedran" wrote in message
...
Hi,

I have a simple script that should open a workbook, run a macro and save

the
file. Everything except the macro part works fine. The file opens and

saves
but macro does not run. Can someone please advise me what am I doing

wrong.
Below is the script.
Thanks

Dim objExcel
Dim objWorkBook
Set objExcel = CreateObject("EXCEL.APPLICATION")
Set objWorkBook = objExcel.Workbooks.Open("C:\File1.xls")
objExcel.DisplayAlerts=False
objExcel.Run "PERSONAL.xls!FORMAT"
objWorkBook.SaveAs "C:\file2.xls",44
objExcel.DisplayAlerts=True
objWorkBook.Close True
objExcel.Quit
Set objWorkBook = Nothing
Set objExcel = Nothing





All times are GMT +1. The time now is 08:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com