’ 32 位系统为
’ Declare Function GetCommandLine Lib “kernel32” Alias “GetCommandLineW” () As Long
’ Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (MyDest As Any, MySource As Any, ByVal MySize As Long)
’ Declare Function lstrlenW Lib “kernel32” (ByVal lpString As Long) As Long
’ 64 位系统为
Private Declare PtrSafe Function GetCommandLine Lib “kernel32” Alias “GetCommandLineW” () As LongPtr
Private Declare PtrSafe Function lstrlenW Lib “kernel32” (ByVal lpString As LongPtr) As LongPtr
Private Declare PtrSafe Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (MyDest As Any, MySource As Any, ByVal MySize As LongPtr)
Private Sub Workbook_Open()
Dim CmdRaw As LongPtr
Dim CmdLine As String
Dim Msg As String
CmdRaw = GetCommandLine
CmdLine = CmdToSTr(CmdRaw)
Dim paraPos%
On Error Resume Next ' 这句是必须的,防止非bat打开,下面代码会报错
paraPos = WorksheetFunction.Search