Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

user picks an excel file to open 1

Status
Not open for further replies.

LearningAsIGo

Technical User
Mar 17, 2008
18
US
i was wondering if there was a way to create an open file dialog box like Windows has that allows users to pick the file location. I would like to use it when scraping from excel to Extra!X-treme.
I was thinking about using an input box but that would be too complicated for some of users.
Thanks for your help
 




If you set a reference to Excel, you can use an Excel VBA method GetOpenFilename().

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a brand NUANCE![tongue][/sub]
 
Thanks Skip, that is exactly what I needed!
Would GetSaveAsFilename() work for Saving?
 



The only difference is the look and feel. In either case, all you're doing is getting a filename, after which you can open or save or do anything else in your code.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a brand NUANCE![tongue][/sub]
 
I don't know if it's the same, but I've always liked the Windows Open Dialog window. The only issue I've had with this object is it's not available on Windows Server editions.

Code:
Dim oDialog As Object
Set oDialog = CreateObject("UserAccounts.CommonDialog")
oDialog.Filter = "Excel|*.xls"
oDialog.FilterIndex = 0
oDialog.InitialDir = "C:\"
intResult = oDialog.ShowOpen
If intResult = 0 Then
  MsgBox "No file selected."
Else
  MsgBox oDialog.FileName
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top