Open Workbook Question

O

oitbso

Both the "GetOpenFilename" and the "Dialogs(xlDialogOpen)" methods as used below will allow you to select a file in a specific folder and then open it.. Is there an advantage of one method over the other, or a situation whereone method is preferred over the other?..Thanks, Ron

MyPath = "C:\test\*.csv"
ChDrive MyPath
ChDir MyPath

FileName = Application.GetOpenFilename
If FileName = "" Then
MsgBox "No File Selected"
End
End If

Workbooks.Open FileName:=FileName

-or-

Application.Dialogs(xlDialogOpen).Show "C:\test\*.csv"
 
G

GS

(e-mail address removed) brought next idea :
Both the "GetOpenFilename" and the "Dialogs(xlDialogOpen)" methods as used
below will allow you to select a file in a specific folder and then open it.
Is there an advantage of one method over the other, or a situation where one
method is preferred over the other?..Thanks, Ron

MyPath = "C:\test\*.csv"
ChDrive MyPath
ChDir MyPath

FileName = Application.GetOpenFilename
If FileName = "" Then
MsgBox "No File Selected"
End
End If

Workbooks.Open FileName:=FileName

-or-

Application.Dialogs(xlDialogOpen).Show "C:\test\*.csv"

There would be a difference in the way you handle if a user cancels, so
look in Help about how that's handled for both methods and add it to
your code.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top