![]() |
Telelogic System Architect (steve huntington) | ![]() |
Topic Title: VBA Problem - CreateTextFile Topic Summary: Created On: 27-Aug-2008 13:24 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
This code for creating an output file has been copied from macro to macro without problem under Windows 2000. My PC has just been replaced with an XP machine and we are now having problems. Curiously the code worked yesterday with the same machine.
Set fs = CreateObject("Scripting.FileSystemObject") fs.CreateTextFile strOutputFileName Set f = fs.GetFile(strOutputFileName) Set ts = f.OpenAsTextStream(ForWriting) When run the macro fails on the second line with a message: Method 'CreateTextFile' of object 'IFileSystem3' failed I have tested this both where the file exists and where a new file is created. |
|
![]() |
|
![]() |
|
Well I identified the problem. The scripts were coded to find the user's "My Documents" folder and save output there. This worked fine with Win2K but is failing with our implementation of XP. I imagine that something doesn't like the embedded blank in the file name.
|
|
![]() |
|
![]() |
|
Tried it on my XP SP3 pc and encountered no problems with blank like below:
strOutputFileName = "C:\Documents and Settings\" & "userid" & "\My Documents\Docs\PCW extract.txt" |
|
![]() |
|
![]() |
|
I was using the system variable that gives the path and this was where the problem was. Depending on the user My Documents may be on the c drive or on a network drive. Maybe it was the variable itself that was the problem.
|
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.