惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security @ Cisco Blogs
P
Privacy & Cybersecurity Law Blog
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Project Zero
Project Zero
C
CERT Recently Published Vulnerability Notes
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cisco Blogs
博客园 - 司徒正美
L
LINUX DO - 热门话题
D
Docker
M
MIT News - Artificial intelligence
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
Jina AI
Jina AI
Last Week in AI
Last Week in AI
Security Latest
Security Latest
The Hacker News
The Hacker News
L
Lohrmann on Cybersecurity
Y
Y Combinator Blog
A
Arctic Wolf
小众软件
小众软件
T
Threat Research - Cisco Blogs
Know Your Adversary
Know Your Adversary
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
腾讯CDC
Google DeepMind News
Google DeepMind News
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - 叶小钗
I
Intezer
NISL@THU
NISL@THU
A
About on SuperTechFans
爱范儿
爱范儿
C
Cybersecurity and Infrastructure Security Agency CISA
D
Darknet – Hacking Tools, Hacker News & Cyber Security
G
Google Developers Blog
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Cyberwarzone
Cyberwarzone
AWS News Blog
AWS News Blog
Engineering at Meta
Engineering at Meta
Latest news
Latest news

博客园 - RayG

How to get data from Oracle DB in silverlight via WCF ? [Ray]How to use CString to create a font family - RayG [Copied] 80 VC++ tips [Copied]The GDI Coordinate Systems My Cheating Death solution in VC++ 3 given points, get the angle between two lines trouble shoot about using BindLayer in MapX with C# [原创] 计算几何常用算法(转) Trouble shooting about installation of ArcSDE 9.2 File type transform between ArcGIS and other major type - RayG [Tips] How to converting a Coverage to a Shapefile ? - RayG [Tips] How to Add New field into Shapefile attribute table in ArcGIS ? 子非鱼,安知鱼之乐? [GuanRui] My program implement on Symbian S60 (#1: File IO) - RayG My XNA HitBee small game [Ray] My GPS (卫星定位接收器) tracker program on Symbian OS Binary Tree ANSI C Implement (2) - RayG Binary Tree ANSI C Implement (1) Graph & Topology & Shortest path
[GuanRui]How to open Path browse dialog in VBA of ArcGIS Desktop ?
RayG · 2007-08-16 · via 博客园 - RayG

there are 2 ways to open a path browse dialog in VB/VBA. and there is a little diffenent between VB and VBA.
check this out ~

Way No.1 : Legacy VB
1. Add a new module in you VB project .
2. Copy & Paste the code below:

Const BIF_RETURNONLYFSDIRS = &H1Private Type SHITEMID
    cb 
As Long
    abID 
As Byte
End Type
Private Type ITEMIDLIST
    mkid 
As SHITEMID
End Type
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 TypePrivate Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As StringAs Long
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As LongPrivate Function GetDir(ByVal szCaption As StringAs String
    
Dim bi As BROWSEINFO, idl As ITEMIDLIST, rtn As Long, pidl As Long, pos As Long, path As String
    bi.hOwner 
= Me.hwnd        (Change Me.hwnd to Application.hwnd when you currently use VBA)
    bi.lpszTitle 
= szCaption
    bi.ulFlags 
= BIF_RETURNONLYFSDIRS
    pidl 
= SHBrowseForFolder(bi)
    path 
= Space(512)
    rtn 
= SHGetPathFromIDList(ByVal pidl, path)
    
If rtn Then pos = InStr(path$, Chr$(0)):   GetDir = Left(path, pos - 1)
End Function

3.In your form, call GetDir(Application.hWnd, "Select a path")

Way No.2 : VB for Application

1. In the VB6 IDE pull down the Project menu and select References. In the resulting dialog box scroll down to "Microsoft Shell Controls and Automation" and check the box, then click [OK]. (This is "Adding a Reference".)

2. Now (after declaring a couple variables, and finding in the VisualC++ help that the constant BIF_RETURNONLYFSDIRS is 1) this code (similar to Peter's) does in fact return JUST the folder name. For "I:\Program Files\Microsoft Visual Studio\VB98\Wizards" it returns the string "Wizards". Not too useful.

3. Now, thanks to Simon Conway-Smith's post, above, we add the code to retrieve the full (drive and) path from shlFolder.Items.Item.Path.

Here's the code, in the on-click method for a button in a test program that actually works (I just now wrote it).

Private Sub GoButton_Click()
    
Dim shlShell As Variant, shlFolder As Variant
    
Set shlShell = New Shell32.Shell
    
Set shlFolder = shlShell.BrowseForFolder(Me.hWnd, "Select a Folder"1)
    FolderLabel.Caption 
= shlFolder.Title 
    PathLabel.Caption 
= shlFolder.Items.Item.Path 
End Sub

End.