Getting a little closer to having this working (thanks for the previous
ideas!)

I now find that if I pass in my second argument to this code:

Option Explicit
Dim objArgs
Set objArgs = WScript.Arguments

Sub CallExcelMacro(strPath, strEName, strMacro)
Dim objXL
Set objXL = WScript.CreateObject("Excel.Application")
objXL.WorkBooks.Open strPath & strEName
objXL.Visible = FALSE
objXL.Run(strMacro)
objXL.Quit
Set objXL = Nothing
End Sub

Call CallExcelMacro(objArgs(0), objArgs(1), objArgs(2))

so that it's longer than 15 characters, then the script won't run.
Ironically, the strPath variable is longer and doesn't seem to cause any
problem. (So maybe it's something else?)

The code that works (by renaming my spreadsheet to accomodate, which isn't a
long term option) from my other (SAS) program that calls this is:

rc = system('cscript.exe //nologo
"\\inlrc11\abc\mets\general\CallExcelMacro.vbs"
"\\inlrc11\abc\temp\state excel\"
"ST Weekly 70170.xls"
"LoadData"');

(The system function basically calls cscript in command line fashion.)

However, the following bombs:

rc = system('cscript.exe //nologo
"\\inlrc11\abc\mets\general\CallExcelMacro.vbs"
"\\inlrc11\abc\temp\state excel\"
"ST Weekly 701709738.xls"
"LoadData"');

Any thoughts on why the longer Excel filename causes this to bomb? Probably
something dumb I'm doing, but this isn't my main language. Again, many
thanks!

Re: wsharguments length limit? by Richard

Richard
Tue Jun 06 20:14:31 CDT 2006

Hi,

I haven't worked with SAS in years, but I don't think the problem is with
the VBScript. I took your command (in single quotes in you snippet) and
pasted it into a batch file, changed the path to the VBScript to one on my
computer (but a longer path), and created a CallExcelMacro.vbs that simply
echoed the arguments. All of my arguments were the same - only the path to
the VBScript was modified. All arguments echoed correctly.

When I pasted your command I noted there were spaces between each argument,
but I had to remove the carriage returns and put it all on one line. For
troubleshooting, have your VBScript program echo the arguments. Could SAS be
truncating your command? Also, what error message do you get (and is there a
line number)?

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"kmbarz" <kmbarz@discussions.microsoft.com> wrote in message
news:E4596EC6-0E00-4123-A29C-037838843715@microsoft.com...
> Getting a little closer to having this working (thanks for the previous
> ideas!)
>
> I now find that if I pass in my second argument to this code:
>
> Option Explicit
> Dim objArgs
> Set objArgs = WScript.Arguments
>
> Sub CallExcelMacro(strPath, strEName, strMacro)
> Dim objXL
> Set objXL = WScript.CreateObject("Excel.Application")
> objXL.WorkBooks.Open strPath & strEName
> objXL.Visible = FALSE
> objXL.Run(strMacro)
> objXL.Quit
> Set objXL = Nothing
> End Sub
>
> Call CallExcelMacro(objArgs(0), objArgs(1), objArgs(2))
>
> so that it's longer than 15 characters, then the script won't run.
> Ironically, the strPath variable is longer and doesn't seem to cause any
> problem. (So maybe it's something else?)
>
> The code that works (by renaming my spreadsheet to accomodate, which isn't
> a
> long term option) from my other (SAS) program that calls this is:
>
> rc = system('cscript.exe //nologo
> "\\inlrc11\abc\mets\general\CallExcelMacro.vbs"
> "\\inlrc11\abc\temp\state excel\"
> "ST Weekly 70170.xls"
> "LoadData"');
>
> (The system function basically calls cscript in command line fashion.)
>
> However, the following bombs:
>
> rc = system('cscript.exe //nologo
> "\\inlrc11\abc\mets\general\CallExcelMacro.vbs"
> "\\inlrc11\abc\temp\state excel\"
> "ST Weekly 701709738.xls"
> "LoadData"');
>
> Any thoughts on why the longer Excel filename causes this to bomb?
> Probably
> something dumb I'm doing, but this isn't my main language. Again, many
> thanks!