エクセルのマクロで教えて下さい
エクセルのマクロでプリンタ名を取得しています
エクセルの32ビット版と64ビット版で共用できるように下記の記述をしたのですが
32ビット版は問題ないのですが、64版ではエラーが発生します
エラーの原因がわかれば教えて下さい
Option Explicit
'このEnumprintersとMoveMemoryがWin32 API の宣言です。
#If VBA7 And Win64 Then
Type PRINTER_INFO_1
flags As LongPtr
pPDescription As LongPtr
pName As LongPtr
pComment As LongPtr
#Else
Type PRINTER_INFO_1
flags As Long
pPDescription As Long
pName As Long
pComment As Long
End Type
#End If
Private Const PRINTER_ENUM_LOCAL = &H2
#If VBA7 And Win64 Then
Private Declare PtrSafe Function Enumprinters Lib "WINSPOOL.DRV" Alias "EnumPrintersA" _
(ByVal flags As LongPtr, ByVal Name As String, ByVal Level As LongPtr, pPrinterEnum As Any, _
ByVal cdBuf As LongPtr, pcbNeeded As LongPtr, pcReturned As LongPtr) As Long
Private Declare PtrSafe Sub MoveMemory Lib "KERNEL32" Alias "RtlMoveMemory" _
(Dest As Any, Source As Any, ByVal length&)
#Else
Private Declare Function Enumprinters Lib "WINSPOOL.DRV" Alias "EnumPrintersA" _
(ByVal flags As Long, ByVal Name As String, ByVal Level As Long, pPrinterEnum As Any, _
ByVal cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long
Private Declare Sub MoveMemory Lib "KERNEL32" Alias "RtlMoveMemory" _
(Dest As Any, Source As Any, ByVal length&)
#End If
お礼
ご丁寧に有難うございました。 良く分かりました。