2017-12-11 32 views
1

32ビットExcelでうまく動作するコードがあります。 コードは64ビット版では機能しません。 64ビットExcelで貼り付け宣言をコピーすると、エラーは発生しません。 宣言は赤で、認識されません。64ビットOSのコマンドライン引数

このコードは、コマンドライン引数を取得するために使用されます。

私が走ったのであれば、たとえば、: Excelを起動し、「C:\ GD \エドゥ最近\ ParametersProject.xlsm」/p/"kjh%dg.pdf」を それは私が解析し、決定することができる文字列を返します入力パラメータ: "C:\ GD \ Edu Recent \ ParametersProject.xlsm" /p/"kjh%dg.pdf "

私はどのようにシフトを行いますか?ここで

はコードです:

'I declared this code in a module called Parameters: 

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) 


Public Function CmdLineToStr() As String 

' 
' Returns the command line in the call to Excel 
' 
Dim Buffer() As Byte 
Dim StrLen As Long 
Dim CmdPtr As Long 

CmdPtr = Parameters.GetCommandLine() 
If CmdPtr > 0 Then 
    StrLen = lstrlenW(CmdPtr) * 2 
    If StrLen > 0 Then 
    ReDim Buffer(0 To (StrLen - 1)) As Byte 
    CopyMemory Buffer(0), ByVal CmdPtr, StrLen 
    CmdLineToStr = Buffer 
    End If 
End If 

End Function 

そして...

'I declared this code in the Workbook open: 

Sub workBook_open() 
    MsgBox Parameters.CmdLineToStr 
End Sub 

答えて

関連する問題