Issues with the OpenText function with Excel 2004

L

Liam Doyle

Hi all,

I have written a vb macro for excel to work cross platform. In this macro it
prompts the user to find a CSV file and then opens it (which it then copies/
pastes into my template). The basic code for the mac section is:

sImportFile = Application.GetOpenFilename(, , "Please select your class list")
If sImportFile <> False Then
Workbooks.OpenText FileName:=sImportFile, DataType:=xlDelimited,
Comma:=True

This worked on Excel v.X but now on 2004 it tells me it can't find the file (I
have checked multiple files and checked that they're there ;-))

Anyone have any idea why this might not work?

Thanks a lot in advance,

Liam
 
J

JE McGimpsey

Liam Doyle said:
I have written a vb macro for excel to work cross platform. In this macro it
prompts the user to find a CSV file and then opens it (which it then copies/
pastes into my template). The basic code for the mac section is:

sImportFile = Application.GetOpenFilename(, , "Please select your class
list")
If sImportFile <> False Then
Workbooks.OpenText FileName:=sImportFile, DataType:=xlDelimited,
Comma:=True

This worked on Excel v.X but now on 2004 it tells me it can't find the file
(I
have checked multiple files and checked that they're there ;-))

Anyone have any idea why this might not work?

Works fine for me: XL04, OSX 10.3.4.

Exactly what error are you getting? On which line of code are you
getting the error?

Are the files local or remote? If remote, do you have permission to read
the files, as well as the directory?
 
G

Guest

Thanks for the reply.

I'm getting a 1004 "file-name" file not found. The files are local, and i'm
getting the error in the Workbooks.OpenText line.

I'm using the test-drive for compatibility testing while i'm waiting for my CD
to arrive, could that be a problem by any chance?

liam
 
L

Liam Doyle

Sorry that post was me before.

Liam
-----Original Message-----

Thanks for the reply.

I'm getting a 1004 "file-name" file not found. The files are local, and i'm
getting the error in the Workbooks.OpenText line.

I'm using the test-drive for compatibility testing while i'm waiting for my CD
to arrive, could that be a problem by any chance?

liam
macro
it
.
 
L

Liam Doyle

I just found the problem. When i call getOpenFilename, and query the path i
get returned after i find my file, it gives me the wrong file path :p

i get HD050141_10_3:Users:itss:Desktop:inqf12e0.csv instead of
HD050141_10_3:Users:itss:Desktop:Templates and Class Lists:inqf12e0.csv,
where it actually resides.

Any ideas why this method is not returning the correct path?

thanks again for your help

liam
 
B

Bernard Rey

Liam Doyle wrote :
I just found the problem. When i call getOpenFilename, and query the path i
get returned after i find my file, it gives me the wrong file path :p

i get HD050141_10_3:Users:itss:Desktop:inqf12e0.csv instead of
HD050141_10_3:Users:itss:Desktop:Templates and Class Lists:inqf12e0.csv,
where it actually resides.

Any ideas why this method is not returning the correct path?

I have no idea why or how. But I could find out that if the selection Window
is set to standard "list view", you will not get the names of the subfolder,
and only the names up to the one that's displayed in the drop-down menu (in
the example you give, I guess it must have been the "Desktop" folder).

Now, if you set that window to "column view" or if you manage to display the
expected folder in the drop-down menu (double-cliking the folder icons in
the list?), you'll have the correct file location.

I get the same behavior in Excel X and in Excel:2001 (under Classic)...

Hard to say if there's a workaround, other than insisting upon the need to
have the expected file displayed directly in the selection Window.
 
B

Bob Greenblatt

Liam Doyle wrote :


I have no idea why or how. But I could find out that if the selection Window
is set to standard "list view", you will not get the names of the subfolder,
and only the names up to the one that's displayed in the drop-down menu (in
the example you give, I guess it must have been the "Desktop" folder).

Now, if you set that window to "column view" or if you manage to display the
expected folder in the drop-down menu (double-cliking the folder icons in
the list?), you'll have the correct file location.

I get the same behavior in Excel X and in Excel:2001 (under Classic)...

Hard to say if there's a workaround, other than insisting upon the need to
have the expected file displayed directly in the selection Window.
This was a problem with Excel 2001. I thought it had been fixed with Excel
X, yet you are reporting that it is still broken. With 2001, the path was
incorect if you simply clicked on the disclusure triangles rather than
double clicking the folders.
 
B

Bernard Rey

Bob Greenblatt wrote :
This was a problem with Excel 2001. I thought it had been fixed with Excel
X, yet you are reporting that it is still broken. With 2001, the path was
incorect if you simply clicked on the disclusure triangles rather than
double clicking the folders.

Well, it's still there! I figured out, just after having sent my reply, it
had been discussed here quite a while ago.

And it's still the same: clicking the disclosure triangles isn't enough for
the intermediate folders to be counted in the complete file path. And thus,
the selected file is considered as being located directly inside the folder
that is listed in the drop-down menu...
 

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