Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open text files with spaces in pathname

Status
Not open for further replies.

ugwings

IS-IT--Management
Dec 19, 2001
5
0
0
I am running into an error 52 problem when I try to open a file with a space in the name. I have tried quoting and unquoting but to no avail. Here is an example:

FileName = Chr(34) "\gem detail.txt" & Chr(34)
FileNumber = FreeFile
Open FileName For Input As FileNumber

What I am doing wrong?
 
You could try a couple of things.....

First try and take out the "\" in the file name.

If that doesn't work, try using the full name of the file including the drive and directories (i.e. "C:\Program Files\gen detail.txt").

Hope this helps...

John
 
I think you need the full name:
[tt]FileName = "C:\ADir\ASub\gem detail.txt"[/tt]
 
Thanks for the tips. The problem occurs if I have any space in the full pathname. As an example:

C:\Documents and Settings\steve\My Documents\gem details.txt

Any suggestions?
 
Just out of curiosity, would a wildcard work, somehow?

FileName = "C:\Documents and Settings\steve\My Documents\gem*details.txt"
 
Hi John,

You were right, I needed to place # before the FileNumber variable.

Thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top