I've copied this from a how to script tutorial. I can't get it to run
without the compilation error: 800A0401
It's suppore to be an example of how to write to a file.
I run it at a command prompt in w2k sp4 by typing cscript writeToFile.vbs
This has got to be a simple problem but not so simple for me. My beginner
VBscript book is in the mail. Any ideas?
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile =
objFSO.OpenTextFile("results.txt", 2, True)
objTextFile.WriteLine("serverName") objTextFile.Close





writeToFile.vbs(2, 57) Microsoft VBScript compilation error: Expected end of
statement

Re: VBScript compilation error: Expected end of statement by Bob

Bob
Sun Aug 03 09:35:27 CDT 2003

David Best wrote:
> I've copied this from a how to script tutorial. I can't get it to run
> without the compilation error: 800A0401
> It's suppore to be an example of how to write to a file.
> I run it at a command prompt in w2k sp4 by typing cscript
> writeToFile.vbs This has got to be a simple problem but not so simple
> for me. My beginner VBscript book is in the mail. Any ideas?
> Set objFSO = CreateObject("Scripting.FileSystemObject") Set
> objTextFile = objFSO.OpenTextFile("results.txt", 2, True)
> objTextFile.WriteLine("serverName") objTextFile.Close

You've got multiple statements that look like they're on the same line. Is
this a problem with your copy-and-paste? Or is this how it looks in your
page? It should look like this:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile =objFSO.OpenTextFile("results.txt", 2, True)
objTextFile.WriteLine("serverName")
objTextFile.Close

Bob Barrows



Re: VBScript compilation error: Expected end of statement by David

David
Mon Aug 04 16:10:25 CDT 2003

Thanks Bob: It looked like that on the tutorial web page and I had word
wrap on my notepad editor. I copied and ran yours and I fixed mine too.
Thanks for the reply.
"Bob Barrows" <reb_01501@yahoo.com> wrote in message
news:uT156xcWDHA.2568@tk2msftngp13.phx.gbl...
> David Best wrote:
> > I've copied this from a how to script tutorial. I can't get it to run
> > without the compilation error: 800A0401
> > It's suppore to be an example of how to write to a file.
> > I run it at a command prompt in w2k sp4 by typing cscript
> > writeToFile.vbs This has got to be a simple problem but not so simple
> > for me. My beginner VBscript book is in the mail. Any ideas?
> > Set objFSO = CreateObject("Scripting.FileSystemObject") Set
> > objTextFile = objFSO.OpenTextFile("results.txt", 2, True)
> > objTextFile.WriteLine("serverName") objTextFile.Close
>
> You've got multiple statements that look like they're on the same line. Is
> this a problem with your copy-and-paste? Or is this how it looks in your
> page? It should look like this:
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile =objFSO.OpenTextFile("results.txt", 2, True)
> objTextFile.WriteLine("serverName")
> objTextFile.Close
>
> Bob Barrows
>
>