![]() |
RunAutoMacros does not work correctly from vbscript!
Hi
I create an Excel workbook through vbscript: Set objXL = WScript.CreateObject("Excel.Application") objXL.Visible = TRUE set objWkB = objXL.WorkBooks.add( "book.xlt" ) After creating I pass the parameters into the first worksheet: Set colArgs = WScript.Arguments For i = 0 to colArgs.Count - 1 objXL.Cells(i + 1, 1).Value = "Parameter(" & i & ")" objXL.Cells(i + 1, 2).Value = colArgs(i) Next After this I try to run "Open" macro by command: objXL.WorkBooks.Item(1).RunAutoMacros(1) Problem is that the autoOpen subroutine is called right after workbook.add command when there are no parameters on the worksheet. When .RunAutoMacros command is executed the control never passes to autoOpen subroutine! I have Win XP with latest updates and Office 2000 with SP3. Does anyone have a solution to this. Juha |
RunAutoMacros does not work correctly from vbscript!
Try it without the Items-keyword, like this: Dim objXL Dim objWkB Set objXL = WScript.CreateObject("Excel.Application") objXL.Visible = TRUE Set objWkB = objXL.WorkBooks.Add("book.xlt") Set colArgs = WScript.Arguments For i = 0 to colArgs.Count - 1 objXL.Cells(i + 1, 1).Value = "Parameter(" & i & ")" objXL.Cells(i + 1, 2).Value = colArgs(i) Next objXL.WorkBooks(1).RunAutoMacros(1) Hans "Juha Vehvilainen" schreef in bericht ... Hi I create an Excel workbook through vbscript: Set objXL = WScript.CreateObject("Excel.Application") objXL.Visible = TRUE set objWkB = objXL.WorkBooks.add( "book.xlt" ) After creating I pass the parameters into the first worksheet: Set colArgs = WScript.Arguments For i = 0 to colArgs.Count - 1 objXL.Cells(i + 1, 1).Value = "Parameter(" & i & ")" objXL.Cells(i + 1, 2).Value = colArgs(i) Next After this I try to run "Open" macro by command: objXL.WorkBooks.Item(1).RunAutoMacros(1) Problem is that the autoOpen subroutine is called right after workbook.add command when there are no parameters on the worksheet. When .RunAutoMacros command is executed the control never passes to autoOpen subroutine! I have Win XP with latest updates and Office 2000 with SP3. Does anyone have a solution to this. Juha |
All times are GMT +1. The time now is 08:02 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com