64位Windows操作系统下Autocad VBA通用文件夹对话框代码

编程入门 行业动态 更新时间:2024-10-13 06:15:10

64位Windows操作系统下Autocad VBA通用文件夹<a href=https://www.elefans.com/category/jswz/34/1761322.html style=对话框代码"/>

64位Windows操作系统下Autocad VBA通用文件夹对话框代码

 以下代码为浏览文件夹对话框通用代码,返回文件夹。

'Code courtesy of Terry KreftPrivate Type BROWSEINFOhOwner As LongPtrpidlRoot As LongPtrpszDisplayName As StringlpszTitle As StringulFlags As Longlpfn As LongPtrlParam As LongPtriImage As LongEnd TypePrivate Declare PtrSafe Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As LongPrivate Declare PtrSafe Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Private Const BIF_RETURNONLYFSDIRS = &H1
Public Function BrowseDirectory(szDialogTitle As String) As String
On Error GoTo Err_BrowseDirectoryDim X As Long, bi As BROWSEINFO, dwIList As LongDim szPath As String, wPos As IntegerWith bi'.hOwner = hWndAccessApp.lpszTitle = szDialogTitle.ulFlags = BIF_RETURNONLYFSDIRSEnd WithdwIList = SHBrowseForFolder(bi)szPath = Space$(512)X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)If X ThenwPos = InStr(szPath, Chr(0))BrowseDirectory = Left$(szPath, wPos - 1)ElseBrowseDirectory = ""End If
Exit_BrowseDirectory:Exit Function
Err_BrowseDirectory:MsgBox Err.Number & " - " & Err.DescriptionResume Exit_BrowseDirectory
End Function
Public Sub TestOpeningDirectory()
On Error GoTo Err_TestOpeningDirectoryDim sDirectoryName As StringsDirectoryName = BrowseDirectory("Find and select where to export the Excel report files.")If sDirectoryName <> "" Then MsgBox "You selected the '" & sDirectoryName & "' directory.", vbInformationExit_TestOpeningDirectory:Exit SubErr_TestOpeningDirectory:MsgBox Err.Number & " - " & Err.DescriptionResume Exit_TestOpeningDirectory
End Sub

更多推荐

64位Windows操作系统下Autocad VBA通用文件夹对话框代码

本文发布于:2024-02-06 12:00:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1748788.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   文件夹   操作系统   代码   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!