Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Does Open File For Output As #1 work in VBS?

808 views
Skip to first unread message

McKirahan

unread,
Feb 13, 2008, 2:16:26 PM2/13/08
to
"XP" <X...@discussions.microsoft.com> wrote in message
news:24359C29-904B-4235...@microsoft.com...
> I'm scripting a VBS file to copy records from multiple text files and
combine
> them into one single file. The text files are fixed width and I want to
copy
> an entire record at a time.
>
> I have done this in VBA using code like:
>
> Open MyDestinationFile For Output As #1
>
> This method fails on the line shown, but I'm unsure whether it is due to
an
> error I made or whether this just can't be used in a script file. If this
> method won't work, could someone please point me in the right direction
for
> doing what I need?

VBScript uses the FileSystemObject for working with files.
Visit http://www.w3schools.com for useful information.

If you just want to merge files then you could just use the
command line's "copy" as in:
copy /b 1.txt+2.txt merged
or
copy /b *.txt merged


Paul Randall

unread,
Feb 13, 2008, 2:52:43 PM2/13/08
to

"XP" <X...@discussions.microsoft.com> wrote in message
news:24359C29-904B-4235...@microsoft.com...
> I'm scripting a VBS file to copy records from multiple text files
> and combine
> them into one single file. The text files are fixed width and I want
> to copy
> an entire record at a time.
>
> I have done this in VBA using code like:
>
> Open MyDestinationFile For Output As #1
>
> This method fails on the line shown, but I'm unsure whether it is
> due to an
> error I made or whether this just can't be used in a script file. If
> this
> method won't work, could someone please point me in the right
> direction for
> doing what I need?
>
> Thanks much for your assistance.

There are some significant differences between VBA and VBScript.
These are explained in the Windows Script 5.6 Documentation,
SCRIPT56.CHM, which is probably already on your computer, and which
can be downloaded from the following MSDN search link:
http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=chm&DisplayLang=en

Look in the Contents tab:
-Windows Script Technology
--VBScript
---User's Guide
----VBScript Features not in Visual Basic for Applications
----Visual Basic for Applications Features Not In VBScript

-Paul Randall


XP

unread,
Feb 13, 2008, 3:32:01 PM2/13/08
to
Thanks for responses.

I've adapted my code using OpenTextFile method on FileSystemObject. Needs
perfecting, but will work.

I can't just append the entire files unfortunately, I will be filtering out
certain records.

Thanks again.

McKirahan

unread,
Feb 13, 2008, 3:42:18 PM2/13/08
to
"XP" <X...@discussions.microsoft.com> wrote in message
news:CEA38915-BF9A-4450...@microsoft.com...

> Thanks for responses.
>
> I've adapted my code using OpenTextFile method on FileSystemObject. Needs
> perfecting, but will work.
>
> I can't just append the entire files unfortunately, I will be filtering
out
> certain records.

[snip]

Do you still have a problem?

Post a clear problem statement along with your code and any errors.


0 new messages