Document Level Vbscript Write To Text File & Cancel Print Follow

0
Avatar
Legacy Poster

Hello,

 

I am seeking advice on how to perform the following with VBScripting:

1 - on print, open a text file

2 - write a new line to the file with data populated from a form with one data entry field

3 - close the text file

4 - cancel the print job

 

Overall, I want to use a form with a data entry field and once the print button on the form is clicked the data from the form is entered as a new line in the text file.

I am also seeking to have a date/time stamp inserted into the same line and before the document is printed cancel the print job.

 

Please see the script below I am working on. My document has two Template Object Data Sources (i.e., Text1, Text2) which I am trying to use in the script. Text1 is the data entry form field and Text2 is a date/time field.

 

   Dim fso, a
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set a = fso.OpenTextFile("C:\TEST.txt", True)
   a.WriteLine (Text1 & vbTab & Text2)
   a.Close
 
To accomplish the first three steps in the process I tried using the above code during the OnPrintJobStart event but with no success.
 
Any advice on why my script is not working and also how to cancel the print job after the text file is written to would be greatly appreciated.

3 comments

0
Avatar
Legacy Poster
Comment actions Permalink

I figured out how to do what I desire.

0
Avatar
Legacy Poster
Comment actions Permalink

It's good that you figured it out,

Would you mind Sharing it?

 

Thanks

0
Avatar
Legacy Poster
Comment actions Permalink

I too would like to see, file io in VB for Bartender is so much fun. Give me true .net capability please, seagull, in C#. Kinda like in Unity.

Please sign in to leave a comment.