I/O Open with \folder name\ space

CharlesHerrick

Registered User.
Local time
Today, 17:08
Joined
Oct 28, 2003
Messages
20
I want to write an error file using the following statement:

Open "C:\Shared Documents\PreMailError.txt" For Output As #1

I get an invalid directory with that, but it works fine with this one:

Open "C:\PreMailError.txt" For Output As #1

Assume the space in the folder name is the problem. Tried assigning "Shared Documents" to a string variable and using the variable in the Open, with no luck.

Suggestions? Thanks ... Charles
 
Best guess: Assuming the folder exists as you have typed it, it could be, perhaps, a user permissions problem.

Regards,
Tim
 
Workaround....

how about setting up a shortcut to the "C:\Shared Documents\PreMailError.txt" file in the C: Drive and Calling it "C:\PreMailError.txt"
 
The folder exists and I'm running the program as the Admin, so it seems like I would have permission (however, I've only recently installed Win XP and certainly am not an "expert" yet).

I'll try the shortcut suggestion, but still wonder if there is a way to specify a valid directory path that contains a space ....
 
Charles,

A space in the dir name doesn't stop me from doing essentially the same thing, in code, on a Windows 2000 PC.

If you already haven't, create a test folder with a space in its name and try to write a file there. If that succeeds, then you can rule out the generic space in name theory. Otherwise, I'm not sure why I would be able to do this on a W2K machine but you wouldn't on an XP machine -- I'm not an XP user and don't know much about its added features...

Are you sure the string variable you are using is valid? Maybe you're missing a slash. Test this using debug.print or a msgbox...

Dim MyPath as string
MyPath = xnxhshd
Debug.print MyPath

Lastly, an Adminstrator can deny him or herself permission to access a folder, though I'm not sure that's happened here. Maybe there's something special about the Shared Docs folder in XP. A search in the XP Help file -- keywords: folder permissions, permission, Shared Documents -- may yield some helpful information.

Regards,
Tim
 
Tim,

Tried writing to C:\Documents and Settings\Errors\PreMailError.txt and it worked fine! Maybe there is a glitch using Shared Documents ... I'll do some research on that.

Many thanks for your insight.

--Charles
 
Charles,

You're welcome. If you get the time, please post back if you're exposed to any good "gotcha" info on that XP folder.

Regards,
Tim
 
XP NOOB

The shared doc's folder is actually

C:\Documents and Settings\All Users\Documents\

lol - hope that helps ya....
 

Users who are viewing this thread

Back
Top Bottom