I found the following link that got me started http://www.vbforums.com/showthread.php?t=366559, so now I have my code for reading/analyzing comand line parameters. Here is an example of the parm I'm passing in
/e/C:\Program Files\AFP\bgst_before.txt§C:\Program Files\AFP\bgst_after.txt§C:\PROGRAM FILES\A_SHB_REXXCODE\excel_diff.txt§
and here is the sub I have on workbook open
- Private Sub Workbook_Open()
- Dim CmdRaw As Long
- Dim cmdline As String
- Dim n1 As Integer
- CmdRaw = GetCommandLine
- cmdline = CmdToSTr(CmdRaw)
- n1 = InStr(1, cmdline, "/e/") ' Do we have a command ?
- If n1 = 0 Then
- MsgBox "No parameters passed at all"
- cmdline = Mid(cmdline, n1 + 3)
- ' cmline should now contain 3 arguments, each separated by a §
- ' 1 - the left file for comparison
- ' 2 - the right file for comparison
- ' 3 - the diff file from beyond compare or Examdiff that shows the differences
- MsgBox "Command passed ***" & cmdline & "***"
- MsgBox "Length of cmdline " & Len(cmdline)
- Call create_diff_layout(cmdline)
- End If
- MsgBox "About to leave Workbook_open"
- End Sub
The three files (separated by a §) are then processed in my VBA code. Everything works fine, until I exit the sub above.
Suddenly, I'm seeing 3 messages (one for each file specified/opened ?) along the lines of
Can't find Files\AFP\bgst_before.txt§C:\Program.xls Check that the name is correctly spelt etc etc
These messages are issued AFTER the "About to leave Workbook_open" message.
If I run EXACTLY the same code from a function (cheating, and passing the string to the routine that actually does the processing, so I don't go through the cmdline code linked to above), everything works fine.
My question is - based on the link and my code above, is there some code I need to "drop" memory or similar, or can anyone see anything obviously wrong in what I'm doing ?