ich möchte excel aufrufen mit einem Parameter, der den suchbegriff enthält und es sollte dann automatisch ein makro starten, das den suchbegrif sucht.
Wie übergbe ich einen oder 2 Parameter beim excelaufruf an ein Excelmakro?
mfg
Karl
Private Sub Workbook_Open()
Dim AntwortInput As Variant
Dim WS As Worksheet
Dim rng As Range
AntwortInput = Application.InputBox("Bitte Parameter eingeben: ")
If AntwortInput = False Then Exit Sub
For Each WS In ThisWorkbook.Worksheets
Set rng = WS.Cells.Find(What:=AntwortInput)
If Not rng Is Nothing Then
MsgBox "Gefunden in " & WS.Name & "!" & rng.Address(0, 0)
Exit Sub
End If
Next WS
MsgBox "nix gefunden"
End Sub
Private Sub Workbook_Open()
Dim strCmdLine As String, strArguments() As String
Dim lngArgumentsCount As Long
strCmdLine = GetCommandLine()
strCmdLine = Left$(strCmdLine, InStr(strCmdLine & Chr$(0), Chr$(0)) - 1)
If InStr(strCmdLine, "/e") <> 0 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 <> ""
strCmdLine = Mid$(strCmdLine, 2)
ReDim Preserve strArguments(lngArgumentsCount)
If InStr(strCmdLine, "/") <> 0 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
If lngArgumentsCount = 2 Then
Application.Run strArguments(0), strArguments(1)
End If
End If
End If
End Sub