Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Pass switch to Main procedure

Tod,

From what I read there seems to be some dispute about whether this actually
works in VBA, VB yes, VBA not absolute. I tried this code and started Excel
with a /r switch, and I could see that in the result.

Private Declare Function GetCommandLine Lib "kernel32" _
Alias "GetCommandLineA" () As Long

Private Declare Function lstrlen Lib "kernel32" _
Alias "lstrlenA" _
(ByVal lpString As Long) As Long

Private Declare Function lstrcpy Lib "kernel32" _
Alias "lstrcpyA" _
(ByVal lpString1 As String, _
ByVal lpString2 As Long) As Long

Private Sub Form_Load()
Dim lpszCommand As Long
Dim cChars As Long
Dim sCommand As String

lpszCommand = GetCommandLine()
cChars = lstrlen(lpszCommand)
sCommand = Space(cChars + 1)
lstrcpy sCommand, lpszCommand

MsgBox sCommand

End Sub

If that is not what you are meaning, maybe as you instantiate Excel in the
VBScript rather than launch the executable, you could set an environmental
variable and read that in VBA, using the Environ command.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Tod" wrote in message
oups.com...
With VB I can add a switch to the command-line and then use Command
within the VB code to read the switch and run code conditionally based
on the Command value.

Typically with Excel workbooks I use a vbscript to open the workbook
and run the code that is in the Sub Main of Module1. Is there a way I
can pass an argument to the sub from the vbscript?

tod



Reply
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
Stop a Procedure from another procedure Ayo Excel Discussion (Misc queries) 1 October 30th 08 01:42 AM
A procedure should run when one cell switch between false/true - but not with worksheet_calculate or change event... Gunnar Johansson Excel Programming 3 October 19th 04 05:24 PM
Calling a procedure in a procedure N10 Excel Programming 2 August 18th 04 12:49 AM
How to pass an Excel range as an argument to a SQL Server stored Procedure Belinda Excel Programming 7 April 8th 04 11:24 AM


All times are GMT +1. The time now is 12:59 PM.

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

About Us

"It's about Microsoft Excel"