Foo_Man_Chu
Board Regular
- Joined
- Jul 22, 2010
- Messages
- 79
I open a spreadsheet via command line using an argument that will be used in my VBA code. It works as expected. I then open the spreadsheet by clicking on the icon for the spreadsheet. It STILL opens as if I were passing it the command line argument. Please help me!!!!!
Code:
Code:
Code:
Option Base 0
Option Explicit
'api call for obtaining the username
Private Declare Function GetUserName& Lib "advapi32.dll" Alias "GetUserNameW" (ByVal lpBuffer As String, nSize As Long)
Declare Function GetCommandLine Lib "kernel32" Alias "GetCommandLineW" () As Long
Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (MyDest As Any, MySource As Any, ByVal MySize As Long)
Function CmdToSTr(Cmd As Long) As String
Dim Buffer() As Byte
Dim StrLen As Long
If Cmd Then
StrLen = lstrlenW(Cmd) * 2
If StrLen Then
ReDim Buffer(0 To (StrLen - 1)) As Byte
CopyMemory Buffer(0), ByVal Cmd, StrLen
CmdToSTr = Buffer
End If
End If
End Function
Public Sub Auto_Open()
Dim CmdRaw As Long
Dim CmdLine As String
Dim myParam As String
CmdRaw = GetCommandLine
CmdLine = CmdToSTr(CmdRaw)
myParam = Right(CmdLine, 4)
If myParam = "AUTO" Then
.........