Command line parameters to Excel

  • Thread starter Thread starter Tom Walker
  • Start date Start date
T

Tom Walker

Hi,

I would be opening an excel spreadsheet from a
powerbuilder application.

Something like this:

excel myexcelsheet.xls thisistheparam

where "thisistheparam" is my parameter. How would I
access the string "thisistheparam" in workbook_open event?

Thanks,
Tom
 
I've just briefly tested a horrible kludge using a batch file and an
environment variable.
This is tested on Windows XP only, with the call made from a desktop
shortcut, or from shell within VB5.

I created a 2-line batch file, callXL.bat

set xl_command_line=%2 %3 %4 %5 %6 %7 %8 %9
%1

I then call the batch file with the workbook path as the first
parameter, followed by any other parameters

(in a shortcut)
C:\callXL.bat "C:\SJGtest.xls" hello world

(or from VB)
Shell "C:\callXL.bat ""C:\SJGtest.xls"" hello world"

and, in the workbook, it is retrieved using:

Private Sub Test()
MsgBox Environ("xl_command_line")
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top