Write Data To Text File
Hi,
i would like to write data to a text file when printing is finished containing some named data fields and have the text filename named after one named data field:
I have one named data fields which is called ´test´ and some other named data fields productA productB productC
Then the text file ´test.txt´ should look like:
productA productB productC
I have no clue at all how to write this in vbscript. Can you guys hand me some example or reference how to create this? Any clue would be a big help.
Thanks
-
The easiest thing to do is to create a print job log text file via the "Administer>Log File Setup" menu item. Select/deselect any parts of the print job that you wish to log or not log, and how the log files are to be organized. Then from a document level VB Script use the WriteToLog() function to write whatever you want to this file.
Example:
Format.WriteToLog("This text string will be written to my log file.")
0 -
Legacy Poster
★ BarTender Hero ★
Thanks Ian, i looked at this and this works, but i need to write to a log file where the log file has the filename of one of the named data fields, e.g. named data field ´test´ should be logfile test.txt. This way i can write different log filenames based on the contents of the Bartender document . Any idea how to solve this via de log function of Bartender?
0 -
In that case you'll need to go about the business of creating the file in VB Script itself, thus giving you complete freedom on what you wish to create and what to write to it. In VB Script you can do this by using the FileSystemObject(). Please feel free to consult the the VB Script Help system accessed via the "Help>Visual Basic Script Help" menu item. Under the "Language Reference" section you'll find the information under the "Objects" sub-section.
Here is a quick example of creating a text file and writing to it:
Dim fso, MyFileSet fso = CreateObject("Scripting.FileSystemObject") Set MyFile = fso.CreateTextFile("c:\testfile.txt", True) MyFile.WriteLine("This is a test.")MyFile.Close
0 -
Legacy Poster
★ BarTender Hero ★
Thanks Ian for the example.
0 -
Legacy Poster
★ BarTender Hero ★
'Dim btFormat As BarTender.Format Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.CreateTextFile("X:\path_to_where_logfile_is_written\"& filename & ".txt", True) a.WriteLine(datasource1 & vbTab & datasource2 & vbTab & datasource3)
For anyone who might wonder how i write it to a text file from a Bartender document, below you find the code. Note that you need to use data source names so it writes the actual data to a text file which is tab delimited.
0 -
Peter Dyson
★ BarTender Hero ★
Thanks for this, just wondering if this option is available through Professional? I've got a client that is using the system on a single Notebook and doesn't want to spend the money on Automation (also not using all the features).
0 -
Rod Bolt: The Professional edition supports VB script, which can include among many other things, creating and writing to a simple text file. Only the programmatic integration of BarTender requires Automation edition or above.
0 -
mari zeng
★ BarTender Hero ★
i'm trying to do the same thing but i have a serialized barcode and i want to add a new line to the same text file for each barcode. how/where would i do this in Professional edition?
0
Please sign in to leave a comment.
Comments
8 comments