Opening .xls files

V

vrzimmerm

I'm writing a macro that, as a first step, allows the user to open a
spreadsheet file of his/her choice. I am using "
Application.GetOpenFilename" to do this. Even tho the files the
user will open are .xls file types Excel seems to interpret them as
text files. (Whenever I try to manually open one of them Excel's Text
Import Wizard opens.)

How do I write a macro that will enable Excel to open these files once
the user has selected the specific .xls file? (Note: accepting
all the defaults in the Text Import Wizard results in a properly
formatted spreadsheet.)

Many thanks.
 
J

JW

Sounds like something is funky with your code. You should be using
something like this:
Sub footer()
Dim fName As String
fName = Application.GetOpenFilename("Excel Files (*.xls),*.xls" _
, , "Select File")
If fName = "" Or fName = False Then Exit Sub
Workbooks.Open fName
End Sub
 
J

Jim Rech

How do I write a macro that will enable Excel to open these files once the
Dim FName As Variant
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If Not FName = False Then Workbooks.Open FName

If Excel is opening the Text Import Wizard I'm almost positive that's what
they are, despite the extension. Excel analyzes the file itself rather than
rely on the extension.

If that is the case you might want to use the Workbooks.OpenText method and
have the parsing done automatically. Check VB help on OpenText to get all
the parameters.


--
Jim
| I'm writing a macro that, as a first step, allows the user to open a
| spreadsheet file of his/her choice. I am using "
| Application.GetOpenFilename" to do this. Even tho the files the
| user will open are .xls file types Excel seems to interpret them as
| text files. (Whenever I try to manually open one of them Excel's Text
| Import Wizard opens.)
|
| How do I write a macro that will enable Excel to open these files once
| the user has selected the specific .xls file? (Note: accepting
| all the defaults in the Text Import Wizard results in a properly
| formatted spreadsheet.)
|
| Many thanks.
|
 

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