|
From: Jim Gregg on 8 Jul 2008 09:20 Hello, I have a vbscript which creates a text file, add some lines of text, and then tries to save it. The problem is that when I try to save the file, I get an error stating "bad file name or number" with the following line of code: Set objFile = objFSO.CreateTextFile(strPath, True) objFile.Write(strList) objFile.Close strPath is equal to "C:\Program Files\Some App\FILE" where FILE is the name. The application that I am updating this file for expects it to be named FILE with no extension. I can only assume that the error is coming from the fact that vbscript thinks FILE is a directory name. Is there anyway to do this with a text file with no extension? Thanks for any help you can offer. JG
From: McKirahan on 8 Jul 2008 09:50 "Jim Gregg" <crazytek(a)gmail.com> wrote in message news:4b0d9f38-250a-4685-9d92-9537623d2c41(a)c65g2000hsa.googlegroups.com... > Hello, > > I have a vbscript which creates a text file, add some lines of text, > and then tries to save it. The problem is that when I try to save the > file, I get an error stating "bad file name or number" with the > following line of code: > > Set objFile = objFSO.CreateTextFile(strPath, True) > objFile.Write(strList) > objFile.Close > > strPath is equal to "C:\Program Files\Some App\FILE" where FILE is the > name. The application that I am updating this file for expects it to > be named FILE with no extension. I can only assume that the error is > coming from the fact that vbscript thinks FILE is a directory name. Is > there anyway to do this with a text file with no extension? Thanks for > any help you can offer. The following works for me: Option Explicit Const cFIL = "C:\Temp\FILE" Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") Dim objCTF Set objCTF = objFSO.CreateTextFile(cFIL, True) objCTF.Write("Hello World") Set objCTF = Nothing Set objFSO = Nothing Perhaps, your path "C:\Program Files\Some App\" does not exist. What's your O/S?
From: Richard Mueller [MVP] on 8 Jul 2008 09:43 Jim Gregg wrote: > I have a vbscript which creates a text file, add some lines of text, > and then tries to save it. The problem is that when I try to save the > file, I get an error stating "bad file name or number" with the > following line of code: > > Set objFile = objFSO.CreateTextFile(strPath, True) > objFile.Write(strList) > objFile.Close > > strPath is equal to "C:\Program Files\Some App\FILE" where FILE is the > name. The application that I am updating this file for expects it to > be named FILE with no extension. I can only assume that the error is > coming from the fact that vbscript thinks FILE is a directory name. Is > there anyway to do this with a text file with no extension? Thanks for > any help you can offer. I'm not able to duplicate the problem. I can create a file with no extension (called FILE) with similar code. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net --
From: ekkehard.horner on 8 Jul 2008 09:53 Jim Gregg schrieb: > Hello, > > I have a vbscript which creates a text file, add some lines of text, > and then tries to save it. The problem is that when I try to save the > file, I get an error stating "bad file name or number" with the > following line of code: > > Set objFile = objFSO.CreateTextFile(strPath, True) > objFile.Write(strList) > objFile.Close > > strPath is equal to "C:\Program Files\Some App\FILE" where FILE is the > name. The application that I am updating this file for expects it to > be named FILE with no extension. I can only assume that the error is > coming from the fact that vbscript thinks FILE is a directory name. Is > there anyway to do this with a text file with no extension? Thanks for > any help you can offer. > > JG If there is a directory "C:\Program Files\Some App\FILE", an attempt to .CreateTextFile( "C:\Program Files\Some App\FILE", True ) will fail with a "permission denied" error.
From: mayayana on 8 Jul 2008 10:22 > > If there is a directory "C:\Program Files\Some App\FILE", an attempt > to .CreateTextFile( "C:\Program Files\Some App\FILE", True ) will fail > with a "permission denied" error. That's a different issue and would typically only apply to Vista.
|
Pages: 1 Prev: Modify a .doc document with a macro without Word ? Next: Start - End Time Question |