Open Workbook Question

  • Thread starter Thread starter oitbso
  • Start date Start date
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"
 
(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
 
Back
Top