|
-
Nov 16th, 2005, 04:26 PM
#1
Thread Starter
New Member
Selecting a Path in Excel 2000
I'm using Excel 2000 and I would like to bring up a dialog box that allows the user to select a Path. Does anyone have a solution for this? I've looked at a few API calls but none of them do specifically what I'd like...
Any ideas on how to accomplish this? Up until now I've been using either a textbox to type in the path or a file open dialog box and asking the user to open a file in the directory that wish to select.
Thanks,
Dave
-
Nov 16th, 2005, 04:37 PM
#2
Re: Selecting a Path in Excel 2000
Have you considered using the built-in "File Open" dialog box?
You can call this by using the dialogs collection of the excel application.
There are many arguments that you can use with the show method of the collection, including read-only, file type (.xls , .txt , etc.)....
VB Code:
Application.Dialogs(xlDialogOpen).Show
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Nov 16th, 2005, 05:24 PM
#3
Re: Selecting a Path in Excel 2000
What you want is a BrowseForFolder dialog. You can create one out of all APIs very easy from this example here.
This will keep the user from getting confused with the OpenSave dialogs as they are prompting for a file to open or save.
VB Code:
'Modified example:
Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Const BIF_RETURNONLYFSDIRS = 1
Const MAX_PATH = 260
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Sub Command1_Click()
'KPD-Team 1998
'URL: [url]http://www.allapi.net/[/url]
Dim iNull As Integer, lpIDList As Long, lResult As Long
Dim sPath As String, udtBI As BrowseInfo
With udtBI
'Set the owner window
.hWndOwner = Me.hWnd
'lstrcat appends the two strings and returns the memory address
.lpszTitle = lstrcat("C:\", "")
'Return only if the user selected a directory
.ulFlags = BIF_RETURNONLYFSDIRS
End With
'Show the 'Browse for folder' dialog
lpIDList = SHBrowseForFolder(udtBI)
If lpIDList Then
sPath = String$(MAX_PATH, 0)
'Get the path from the IDList
SHGetPathFromIDList lpIDList, sPath
'free the block of memory
CoTaskMemFree lpIDList
iNull = InStr(sPath, vbNullChar)
If iNull Then
sPath = Left$(sPath, iNull - 1)
End If
End If
MsgBox sPath
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 20th, 2005, 08:39 PM
#4
Thread Starter
New Member
Re: Selecting a Path in Excel 2000
Thanks, I haven't had a chance to try that yet but it sounds like what I am looking for! I'll have to figure out how to make API calls on my own some day. Any suggested reading (preferably free/sites but books are always an option) ?
I've been working on moving from C to C++ and am hopinig to work APIs and MFC into that as well, perhaps it'd be better to wait until I cross that line?
-
Nov 20th, 2005, 08:41 PM
#5
Re: Selecting a Path in Excel 2000
Check out allapi.net for allot of API tutorials and definitions.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 20th, 2005, 08:42 PM
#6
Re: Selecting a Path in Excel 2000
You can find a list of most of them at www.allapi.net and also at MSDN On-Line.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|