title: Pass Argument from VBS to VBA
body: <p>I try to call a VBA subroutine from VBS with passing a string variable from VBS to VBA, but can't find the appropiate syntax:</p>
  
  <pre><code>'VBS:
  '------------------------
  Option Explicit
  
  Set ArgObj = WScript.Arguments 
  Dim strPath
  
  mystr = ArgObj(0) '?
  
  'Creating shell object 
  Set WshShell = CreateObject("WScript.Shell")
  
  'Creating File System Object
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  
  'Getting the Folder Object
  Set ObjFolder = objFSO.GetFolder(WshShell.CurrentDirectory)
  
  'Getting the list of Files
  Set ObjFiles = ObjFolder.Files
  
  'Creat a Word application object
  Set wdApp = CreateObject("Word.Application")
  wdApp.DisplayAlerts = True
  wdApp.Visible = True
  
  'Running macro on each wdS-File
  Counter = 0
  For Each objFile in objFiles
    If UCase(objFSO.GetExtensionName(objFile.name)) = "DOC" Then
      set wdDoc = wdApp.Documents.Open(ObjFolder &amp; "\" &amp; ObjFile.Name, 0, False) 
      wdApp.Run "'C:\Dokumente und Einstellungen\kcichini\Anwendungsdaten\Microsoft\Word\STARTUP\MyVBA.dot'!Test_VBA_with_VBS_Args" (mystr) 'how to pass Argument???
      Counter = Counter + 1
    End if
  Next
  
  MsgBox "Macro was applied to " &amp; Counter &amp; " wd-Files from current directory!"
  
  wdApp.Quit
  Set wdDoc = Nothing
  Set wdApp = Nothing
  
  
  
  '------------------------
  'VBA:
  '------------------------
  Sub Test_VBA_with_VBS_Args()
  
      Dim wdDoc As Word.Document
      Set wdDoc = ActiveDocument
      Dim filename As String
      Dim mystr As String
  
      'mystr = how to recognize VBS-Argument ???
  
      filename = ActiveDocument.name
      MsgBox "..The file: " &amp; filename &amp; " was opened and the VBS-Argument: " &amp; mystr &amp; "recognized!" 
  
      wdDoc.Close
  
  End Sub
  '------------------------
  </code></pre>