LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Passing string as macro parameter

I'm working with some test macros to try and get something real working.

Within VBA, I can call the test2 macro with a string parameter and
everything works:

Sub test2(LOSName)
MsgBox LOSName
End Sub

Sub test3()
test2 ("Hi")
End Sub

However, if I try the same thing from a command line going through my VBS
program, my double quotes are getting stripped away somewhere and I can't
pass in my parameter.

c:\ cscript.exe c:\CallExcelMacro.vbs c:\test.xls test2("Hi")

results in: CallExcelMacro.vbs(14,3) Microsoft Office Excel: The macro
'test2(Hi)' cannot be found.

Any ideas as to what the issue here is? Thanks. The vbs follows:

Option Explicit
Dim objArgs
Set objArgs = WScript.Arguments


Sub CallExcelMacro(strData, strMacro)

Dim objXL
'Dim strData

Set objXL = WScript.CreateObject("Excel.Application")
objXL.WorkBooks.Open strData
objXL.Visible = TRUE
objXL.Run(strMacro)
objXL.Quit
Set objXL = Nothing
End Sub

Call CallExcelMacro(objArgs(0), objArgs(1))
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
passing parameter to a ms query redf1re Excel Programming 6 February 7th 06 10:39 PM
Passing chartobject as a parameter to sub David Cohen Excel Programming 0 September 21st 05 09:58 PM
VB macro - Nested Calls ( Parameter Passing ) Deepak Excel Programming 1 August 3rd 05 04:51 PM
Passing a Sub's name as parameter Stefi Excel Programming 7 June 20th 05 08:48 PM
Passing parameter to a query Dwaine Horton[_3_] Excel Programming 6 April 26th 05 02:24 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"