Hallo Reinhard,
danke für Deine Antwort.
man kann schon mit API die Befehlszeile die Excel aufrief
auslesen, um wieviele Dateien geht es denn circa?
Im Augenblick eine einzige, das werden u.U. bis zu 10. Ist also kein ernsthaftes Problem, die jeweils anzupassen um irgendwelche Macros einzufügen.
In jede müßte halt Ereigniscode für das Ereignis Workbook_Open
rein, also Vba-Code der beim Öffnen der Mappe ausgeführt wird.
Ahja. Ok, ich habe mal ein wenig rumgegoogelt und etwas zusammengeklaut:
Option Explicit
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 Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Private Function GetCommLine() As String
Dim RetStr As Long, SLen As Long
Dim Buffer As String
'Get a pointer to a string, which contains the command line
RetStr = GetCommandLine
'Get the length of that string
SLen = lstrlen(RetStr)
If SLen \> 0 Then
'Create a buffer
GetCommLine = Space$(SLen)
'Copy to the buffer
CopyMemory ByVal GetCommLine, ByVal RetStr, SLen
End If
End Function
Private Sub Workbook\_Open()
Dim myParam As String
Dim i As Integer, j As Integer
myParam = GetCommLine
'Prüfen, ob "/e/" in der Befehlszeile enthalten ist
i = InStr(LCase(myParam), "/e/")
If i \> 0 Then
myParam = Mid$(myParam, i + 3)
j = InStr(myParam, "/")
If j 0 Then myParam = Left(myParam, j - 1)
Columns("A:A").Select
Selection.Find(What:=myParam, After:=ActiveCell, LookIn:=xlFormulas, LookAt \_
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= \_
False, SearchFormat:=False).Activate
End If
End Sub
Das funktioniert auch, wenn der Wert gefunden wird. Wenn der übergebene Wert nicht vorhanden ist, gibt es einen
Laufzeitfehler '91': Objektvariable oder With-Blockvariable nicht festgelegt.
Was fehlt da noch???
Was kann denn dein Managerprogramm so, kann es in die Registry
schreiben oder eine .txt-Datei erstellen?
Nö, nicht wirklich. Ok, ich könnte eine Batchdatei aufrufen, die das dann macht, aber komfortabel ist anders.
VBA-rumstümpernde Grüße
Stefan