Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro from batch file with COMMAND PARAMETERS 1

Status
Not open for further replies.
Mar 21, 2005
9
US
Hi All -

I am trying to use this "<path>\ebrun.exe" "<path>macro.ebm" in a batch file. I need to pass parameters along to the macro. I know the macro can read parameters, because it has a Command$ function. However, I can't find a switch or any other method to populate the parameters..

Any Help would be GRACIOUSLY received.

Thanks, Michelle
 
Delimit the command-line arguments and parse it.

Test.bat
Code:
"C:\Program Files\Attachmate\EXTRA!\Ebrun.exe" "C:\Program Files\Attachmate\EXTRA!\Macros\Temp.ebm" ARG_ONE~ARG_TWO~ARG_THREE
Temp.ebm
Code:
Declare Sub Split(ByRef arr() as Variant, target as String, search as String)

Sub Main()
   Dim arr() As Variant, i As Integer
   
   Call Split(arr, Command$, "~")
   
   For i = 1 to Ubound(arr)
      MsgBox arr(i)
   Next i
End Sub

Private Sub Split(ByRef arr() As Variant, target As String, search As String)
   Dim i As Integer, j As Integer

   i = InStr(1, target, search)
   j = 1

   Do While i > 0
      ReDim Preserve arr(j)
      arr(j) = Trim(Mid(target, 1, i - 1))
      target = Mid(target, i + 1)
      i = InStr(1, target, search)
      j = j + 1
   Loop

   ReDim Preserve arr(j)
   arr(j) = target
End Sub
 
Thanks for posting this! I was able to get the .bat file to launch the macro but when I added the Command part, it bombed. All it needed was to move the Command arguments inside the quotes like so:
Code:
"C:\Program Files\Attachmate\EXTRA!\Ebrun.exe" "C:\Program Files\Attachmate\EXTRA!\Macros\Temp.ebm ARG_ONE~ARG_TWO~ARG_THREE"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top