Open...

Home Search Site Map

Up
Close
Exit
File Search...
Most Frequently Used
New...
Open...
Page Setup...
Permission
Print...
Print Area
Print Preview
Properties
Save
Save As...
Save as Web Page...
Save Workspace...
Send To
Web Page Preview

New! Excel User Group Now Open @ www.excelusergroup.org,

Menu command Type What happens next?
Open... ...

Presents the 'open file' dialog from which files can be selected for opening. 

The default file type is, of course, Excel, but many file types can be opened using the 'files of type' drop-down in the dialog (Above).  It should be noted that if the file is text of a type '*.csv', (comma separated value), it will open automatically in Excel, as any normal Excel file.  If this is undesirable and your intention was to invoke the 'text wizard' then you should rename the file with a *.txt (text file) extension, or remove the extension all together and open the type 'all files *.*' More detail on getting text (and other external data) into Excel can be found here.

VBA Sub wbOpen()
Dim sFileName As String
Dim wb As Workbook
sFileName = Application.GetOpenFilename()
Set wb = Workbooks.Open(Filename:=sFileName)
'Do what you want with workbook here using wb variable
End Sub
 

nb: The GetOpenFilename method of the application object purely collects the file name.  It does not open the file.  You use the string value returned when the dialog is closed to open the file. (see example)

Top

Copyright Nick Hodge 2009. All Rights Reserved.