Open a text file using vbscript 
Author Message
 Open a text file using vbscript

I'm trying to find a method of mass updating some data fields in an
application that runs on an AS400. The application provides the option
to use macros, which can be programmed using it's own language or
VBScript. I'm totally new to vbscript so I thought somebody might be
able to tell me whether it's worth learning vbscript for this
particular application.

So, is it possible to read a 'plain text file' using vbscript so that
I can use the data in the file to populate the data fields via a
macro.

Thanks for any help whatsoever, depending on the answer, I may well
become a regular visitor.

Andy



Wed, 18 May 2005 06:43:11 GMT  
 Open a text file using vbscript
Hi Andy
..here's a link about FSO (the FileSystem Object), which will give you an
idea what is feasible etc. This object you would maybe use to read/write
files etc.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/scri...
ml/jsfsotutor.asp

more documentation abut VBS is here..
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/scri...
ml/vtoriVBScript.asp

greetings
    Armin


Quote:
> I'm trying to find a method of mass updating some data fields in an
> application that runs on an AS400. The application provides the option
> to use macros, which can be programmed using it's own language or
> vbscript. I'm totally new to vbscript so I thought somebody might be
> able to tell me whether it's worth learning vbscript for this
> particular application.

> So, is it possible to read a 'plain text file' using vbscript so that
> I can use the data in the file to populate the data fields via a
> macro.

> Thanks for any help whatsoever, depending on the answer, I may well
> become a regular visitor.

> Andy



Wed, 18 May 2005 07:01:43 GMT  
 Open a text file using vbscript

Quote:
> I'm trying to find a method of mass updating some data fields in an
> application that runs on an AS400. The application provides the option
> to use macros, which can be programmed using it's own language or
> vbscript. I'm totally new to vbscript so I thought somebody might be
> able to tell me whether it's worth learning vbscript for this
> particular application.

I would say "yes" to that.  Not just for this application, though. Once you
start to realize the power in VBScript you'll find yourslef using it for
more and more things.  I'm even saying goodbye to some of my tried-and-true
bacth files these days, because I can have more functionality utillizing VBS
(but I doubt I'll ever give up my beloved command shell!).

Quote:
> So, is it possible to read a 'plain text file' using vbscript so that
> I can use the data in the file to populate the data fields via a
> macro.

Sure is, Armin mentioned the FileSystemObject stuff already so I won't
repeat him.

Quote:
> Thanks for any help whatsoever, depending on the answer, I may well
> become a regular visitor.

This is a *great* group to lurk around in.  I've leeched a couple (ok a few
dozen) scripts from here - minor modifications to suit my environment and my
life is *so* much easier...
Quote:
> Andy



Wed, 18 May 2005 07:16:20 GMT  
 Open a text file using vbscript
Thanks Guys, with such positive feedback I've got to give vbscript a good try.

Thanks again, see you around (well in this group anyway)



Wed, 18 May 2005 22:08:58 GMT  
 Open a text file using vbscript
Andy, here's the boilerplate functions I use for reading data to a file and
writing data to a file.  I am using the standard VBScript "replace" command to
replace all instances of ",<<customer>>," in the file with ",John Doe," and
write to a different output file:

sData = ReadFile("C:\tmp\in.txt")
sData = Replace(sData, ",<<customer>>,", ",John Doe,")
fWrite sData, "C:\tmp\out.txt"

Function ReadFile(FilePath)
 'Given the path to a file, will return entire contents
 ' works with either ANSI or Unicode
 Dim FSO, CurrentFile
 Const ForReading = 1, TristateUseDefault = -2, _
  DoNotCreateFile = False
 Set FSO = createobject("Scripting.FileSystemObject")
 If FSO.FileExists(FilePath) Then
  If FSO.GetFile(FilePath).Size>0 Then
   Set CurrentFile = FSO.OpenTextFile(FilePath, ForReading, _
    False, TristateUseDefault)
   ReadFile = CurrentFile.ReadAll: CurrentFile.Close
  End If
 End If
End Function

Sub fWrite(FilePath, sData)
 'writes sData to FilePath
 With CreateObject("Scripting.FileSystemObject")._
  OpenTextFile(FilePath, 2, True)
  .Write sData: .Close
 End With
End Sub
--
Please respond in the newsgroup so everyone may benefit.
 http://dev.remotenetworktechnology.com
 ----------
 Subscribe to Microsoft's Security Bulletins:
 http://www.microsoft.com/technet/security/bulletin/notify.asp


Quote:
> Thanks Guys, with such positive feedback I've got to give vbscript a good try.

> Thanks again, see you around (well in this group anyway)



Thu, 19 May 2005 01:12:51 GMT  
 Open a text file using vbscript
I try to work also with macro and vbscript and AS400 . I import mostly data
from EXCEL if you get some sources to do that I would very happy, I would
try to get my information directly from ACCESS but I can't find any sources.



Quote:
> I'm trying to find a method of mass updating some data fields in an
> application that runs on an AS400. The application provides the option
> to use macros, which can be programmed using it's own language or
> vbscript. I'm totally new to vbscript so I thought somebody might be
> able to tell me whether it's worth learning vbscript for this
> particular application.

> So, is it possible to read a 'plain text file' using vbscript so that
> I can use the data in the file to populate the data fields via a
> macro.

> Thanks for any help whatsoever, depending on the answer, I may well
> become a regular visitor.

> Andy



Thu, 19 May 2005 04:07:44 GMT  
 Open a text file using vbscript
Eric,

Most of the people here who do this using different emulators almost
always output the data to a text file first. The Access function
'outputTo' always you to create a text file using an access macro. I
would recommend this way.

Quote:

> I try to work also with macro and vbscript and AS400 . I import mostly data
> from EXCEL if you get some sources to do that I would very happy, I would
> try to get my information directly from ACCESS but I can't find any sources.



Fri, 20 May 2005 18:02:46 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Opening text file in a text box using common dialog

2. using isam text driver to open comma delimited text file

3. Open a text file and edit using ReadLine method

4. Open a text file and edit using ReadLine method

5. open a text file in VBScript having 500k characters in length and 5GB

6. VBScript - Open text file

7. Newbie at VBScript - how to open a text file

8. opening / saving files with MS rich text box control (viewing open files)

9. Open file using vbscript in MSDEV5?

10. Accessing text files using vbScript

11. Using Open Statement to import a long text file in Access

12. Using datacontrol to open multiple text files

 

 
Powered by phpBB® Forum Software