我在 Access 2010 中的 VBA 代码有问题。我声明了一个类型,但是当我尝试获取这种类型的变量的指针(使用函数 VarPtr)时,我得到一个compilation error: incompatible type
.
Dim dm As DEVMODE
Dim pd As PRINTER_DEFAULTS
pd.pDevMode = VarPtr(dm) ' the line that throws the error
' pDevMOde is a Long that is supose to contain the adress of the dm variable
Private Type DEVMODE
dmDeviceName As String * CCHDEVICENAME ' (1 To CCHDEVICENAME) As Byte
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME '(1 To CCHFORMNAME) As Byte
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
问题是此代码是在早期版本的 Access 中创建的,并且在 2003 及以下版本中完美运行。我不知道为什么它在 Access 2010 中不起作用。我查看了 2010 和 2003 版本之间的差异,但我没有找到与此相关的任何内容。
有人有线索吗?
谢谢!