LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default cannot get GetOpenFilename to work

Could someone please take a look at this bit of code and tell me what's
wrong with it - I'm stumped, I've tried various things and just cannot
get it to work. I'm using Windows XP and Office 2003 .
Ultimately, I'll want it to default to a network drive, but I can't
even get it to work when starting on C:\. I get a runtime error 1004
which I believe is "file not found".

Sub myOpenFileDialog()
'
' myOpenFileDialog Macro
'
myFilt = "Text Files (*.txt), *.txt" & _
"Comma Separated Values (*.csv), *.csv" & _
"Excel Workbooks (*.xls), *.xls" & _
"All Files (*.*), *.*"
myFilterIndex = 4
myTitle = "Select Data File to Open"

ChDrive "C:\"
ChDir "C:\"
' Get the file name
myDataFileName = Application.GetOpenFilename(FileFilter:=myFilt, _
FilterIndex:=myFilterIndex, Title:=myTitle)

' Exit if user cancels dialog box
If myDataFileName = False Then
MsgBox "No file Selected"
Exit Sub
End If

' Show myDataFileName Result
MsgBox "Data Filename = " & myDataFileName

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
GetOpenFilename Craig[_2_] Excel Programming 4 December 15th 05 04:36 PM
GetOpenFileName Tomski[_4_] Excel Programming 3 October 4th 05 03:34 PM
GetOpenFilename Jenny Excel Programming 2 October 22nd 04 01:38 PM
GetOpenFilename Wolfgang Excel Programming 1 February 6th 04 07:37 PM
getopenfilename inquirer Excel Programming 1 December 3rd 03 11:37 AM


All times are GMT +1. The time now is 09:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"