代码无法正常工作
几年来,我一直在我的代码中使用以下函数,现在在32位版本的AutoCAD上,现在我的公司正在切换到64位,我很难让它工作。如果有人有时间看一看,看看他们是否知道为什么它可能无法正常工作,我将不胜感激。非常感谢。Function GetCurrentPrinters() As Variant
Dim Buffer() As Long
Dim PrintInfo() As PRINTER_INFO_4
Dim NumBytes As Long, NumNeeded As Long, NumPrinters As Long
Dim RetVal As Long, c As Long, Success As Boolean
Dim AllPrinters() As String
NumBytes = 3072
ReDim Buffer(0 To (NumBytes \ 4) - 1) As Long
Success = EnumPrinters(PRINTER_ENUM_LOCAL + PRINTER_ENUM_CONNECTIONS, "", 4, Buffer(0), NumBytes, NumNeeded, NumPrinters)
If Success Then
If NumNeeded > NumBytes Then
NumBytes = NumNeeded
ReDim Buffer(0 To (NumBytes \ 4) - 1) As Long
Success = EnumPrinters(PRINTER_ENUM_LOCAL + PRINTER_ENUM_CONNECTIONS, "", 4, Buffer(0), NumBytes, NumNeeded, NumPrinters)
If Not Success Then
MsgBox "Error Enumerating Printers", vbInformation, "Message"
End If
End If
Else
MsgBox "Error Enumerating Printers", vbInformation, "Message"
End If
If Success And NumPrinters > 0 Then
ReDim PrintInfo(0 To NumPrinters - 1) As PRINTER_INFO_4
For c = 0 To NumPrinters - 1
PrintInfo(c).pPrinterName = Space(StrLen(Buffer(c * 3)))
RetVal = PtrToStr(PrintInfo(c).pPrinterName, Buffer(c * 3))
PrintInfo(c).pServerName = Space(StrLen(Buffer(c * 3 + 1)))
RetVal = PtrToStr(PrintInfo(c).pServerName, Buffer(c * 3 + 1))
PrintInfo(c).Attributes = Buffer(c * 3 + 2)
Next c
ReDim Preserve AllPrinters(NumPrinters)
For c = 0 To NumPrinters - 1
AllPrinters(c) = PrintInfo(c).pPrinterName
Next c
Else
MsgBox "No Printers Found", vbInformation, "Message"
End If
GetCurrentPrinters = AllPrinters
End Function
我有一个问题,vba 2013代码在2016年不工作简单的修复是vbaman打开代码得到了工具,然后参考,在我的情况下,它有一个2013库文件链接,不再存在,取消复选框保存等,现在工作良好。 LongPtr与Long
http://blog.nkadesign.com/2013/vba-for-32-and-64-bit-systems/ 感谢BIGAL和yosso的回复。我试过你的两个建议,但不幸的是,两个似乎都不起作用。
页:
[1]