2017-03-09 25 views
1

私は、Excelは、VBのコードを実行していると私はオフィス2016年に試験したとき、このプロジェクトのコードは、64ビットで使用するために更新する必要がありますVBAコードを64ビットExcelと互換性のある方法にするには?

以下のエラーを与え、今32バージョンと罰金だとシステム

私はvbが良くないので、私はコードを更新することに問題があります。これは私の次のコードとどのように64ビット互換性のためにそれを更新することです、

Declare Function GetSystemDirectory Lib "kernel64" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long 
'a íÌÈ Ãí íßæä åäÇß ÌÏæá Úáì ÞÇÚÏÉ ÇáãÚáæãÇÊ ÈÅÓã 
'a QtrDate 
Global G_SystemPath As String 

Function L_FileExist(L_FName As String) As Boolean 
'a chick if the file given is found or not 
'a input File Name 
'a Output 
'a True : if found 
'a False : if not found 
    L_FileExist = Not (Trim(Dir(L_FName)) = "") 
End Function 
Public Function GetWindowsSysDir() As String 
    Dim strBuf As String 
    strBuf = Space$(250) 
    If GetSystemDirectory(strBuf, 250) Then 
     GetWindowsSysDir = StringFromBuffer(strBuf) 
     AddDirSep GetWindowsSysDir 
    End If 
End Function 

Public Function StringFromBuffer(Buffer As String) As String 
    Dim nPos As Long 
    nPos = InStr(Buffer, vbNullChar) 
    If nPos > 0 Then 
     StringFromBuffer = Left$(Buffer, nPos - 1) 
    Else 
     StringFromBuffer = Buffer 
    End If 
End Function 

Public Sub AddDirSep(strPathName As String) 
    strPathName = RTrim$(strPathName) 
    If Right$(strPathName, 1) <> "\" Then 
     strPathName = strPathName & "\" 

    End If 
End Sub 


Sub L_Secrit() 
G_SystemPath = GetWindowsSysDir 
If L_FileExist(G_SystemPath & "MSAYAR.DLL") Then 
    Sheet1.Cells(400, 2) = " " 
    Sheet1.Cells(401, 2) = " " 
    Sheet1.Cells(402, 2) = " " 
+0

[VBAコード64ビットシステム](http://stackoverflow.com/questions/26198994/vba-code-64-bit-systems)の可能な複製 – Veve

答えて

1

最初の行はここ

#if VBA7 then 
    Declare PtrSafe Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long 
#else 
    Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long 
#end if 

すべきは、64ビットのWin32API呼び出しを見つけることnice resourceです。

+0

コード内の他のものを変更する必要がありますか? – Bodhi

+0

この行を変更すると、少なくともAPI呼び出しは互換性があります。私はあなたのコードが何をしているのか、何が使われているのか分かりません。なぜあなたはそれを試して試してみませんか? –

+0

はい..私はそれをテストし、その正常に動作しています。 – Bodhi

関連する問題