gpt4 book ai didi

vba - 出现编译错误: User-defined type not defined when working to make an old 32-bit template into a Word 2012 64-bit template

转载 作者:行者123 更新时间:2023-12-02 10:48:23 26 4
gpt4 key购买 nike

我有一个照片模板,可以从文件中获取照片并将其放在Word文档的单独框中。该文件曾经是只能在旧计算机上运行的Word 2003 32位文件。

我已将文件转换为64位以在我们的新计算机中使用,并将其保存为启用了单词宏的模板。
这消除了我遇到的一堆问题,但最后一点是...起初它显示检测到不明确的名称,但是在关闭并重新启动后,它开始显示编译错误:未定义用户定义类型,突出显示了代码的第一行下面,经过大量研究我找不到解决方案。
请帮忙,我真的需要这个宏才能工作

Public Declare PtrSafe Function SHBrowseForFolder Lib "shell32.dll" (ByRef lpbi As BROWSEINFO) As Long*

Public Declare PtrSafe Function SHGetPathFromIDList Lib "shell32.dll" (ByVal pidList As Long, ByVal lpBuffer As String) As Long

'corrected
Public Declare PtrSafe Function SHGetSpecialFolderLocation Lib "shell32.dll" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, ByRef pidl As Long) As Long



Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadId As Long
End Type


Private Declare PtrSafe Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Declare PtrSafe Function CreateProcessA Lib "kernel32" (ByVal _
lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long

Private Declare PtrSafe Function CloseHandle Lib "kernel32" (ByVal _
hObject As Long) As Long


Private Type FILETIME ' 8 Bytes
dwLowDateTime As Long
dwHighDateTime As Long
End Type

最佳答案

似乎您缺少TypeBROWSEINFO枚举,请参见此处的示例:

http://www.jkp-ads.com/Articles/apideclarations.asp

#If VBA7 Then
Private Type BROWSEINFO
hOwner As LongPtr
pidlRoot As LongPtr
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As LongPtr
lParam As LongPtr
iImage As Long
End Type

Private Declare PtrSafe Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" _
(lpBrowseInfo As BROWSEINFO) As LongPtr
#Else
Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" _
(lpBrowseInfo As BROWSEINFO) As Long
#End If
Private Const BIF_RETURNONLYFSDIRS = &H1

关于vba - 出现编译错误: User-defined type not defined when working to make an old 32-bit template into a Word 2012 64-bit template,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28416636/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com