|  
                                             
	Hallo, 
	  
	ich habe mir deinen code kaum angesehen. Woher hast du denn die Info mit den Switches /q und /a? 
	Denn hier: 
	https://support.microsoft.com/de-de/help/291288/description-of-the-startup-switches-for-excel 
	kann ich weder /q noch /a finden? Kann das sein, dass du das mit Word vewechelst? 
	  
	Ich habe versucht, den Code von Nepumuk für dich anzupassen 
	http://www.herber.de/forum/archiv/1180to1184/1183170_Kommandozeile_aus_Excelaufruf_in_Makro_auswerten.html 
Option Explicit
Private Declare Function GetCommandLine Lib "kernel32.dll" Alias "GetCommandLineA" () As Long
Private Declare Function lstrlen Lib "kernel32.dll" Alias "lstrlenA" ( _
    ByVal lpString As Any) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" ( _
    ByRef pDst As Any, _
    ByRef pSrc As Any, _
    ByVal ByteLen As Long)
    
Private Sub Workbook_Open()
    Dim Args() As String
    Args = getCommandLineArgs()
    MsgBox Args(0)
End Sub
Private Function getCommandLineArgs()
'von Nepumuk gestohlen und angepasst:
'      http://www.herber.de/forum/archiv/1180to1184/1183170_Kommandozeile_aus_Excelaufruf_in_Makro_auswerten.html
    Dim strCmdLine As String, strArguments() As String
    Dim lngArgumentsCount As Long
    Dim lngReturn As Long, lngLength As Long
Stop
    lngReturn = GetCommandLine
    lngLength = lstrlen(lngReturn)
    
    If CBool(lngLength) Then
        strCmdLine = Space$(lngLength)
        Call CopyMemory(ByVal strCmdLine, ByVal lngReturn, lngLength)
    End If
    
    strCmdLine = Left$(strCmdLine, InStr(strCmdLine & vbNullChar, vbNullChar) - 1)
    
    If CBool(InStr(strCmdLine, "/e")) Then
        If Len(strCmdLine) - InStr(strCmdLine, "/e") > 1 Then
            strCmdLine = Mid$(strCmdLine, InStr(strCmdLine, "/e") + 2)
            strCmdLine = Left$(strCmdLine, InStr(strCmdLine, " ") - 1)
            strCmdLine = Trim$(strCmdLine)
            Do While strCmdLine <> vbNullString
                strCmdLine = Mid$(strCmdLine, 2)
                ReDim Preserve strArguments(lngArgumentsCount)
                If CBool(InStr(strCmdLine, "/")) Then
                    strArguments(lngArgumentsCount) = _
                        Left$(strCmdLine, InStr(strCmdLine, "/") - 1)
                Else
                    strArguments(lngArgumentsCount) = strCmdLine
                End If
                
                strCmdLine = Right$(strCmdLine, Len(strCmdLine) - _
                    Len(strArguments(lngArgumentsCount)))
                lngArgumentsCount = lngArgumentsCount + 1
            Loop
            
            getCommandLineArgs = strArguments
        
        End If
    End If
    
End Function
	  
	Jetzt kannst du ja statt msgbox args(0) die Datei öffenen und drucken. 
	Der Aufruf muss jetzt allerdings so erfolgen: 
	"C:\Program Files\Microsoft Office\root\Office16\excel.exe" /e/c:\test\Ordner\inputFile.xls "C:\Macro.xlsm" 
	  
	kommst du klar? 
	Grüße, Ulrich 
     |