Results 1 to 5 of 5
  1. #1
    Fairlane is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    13

    Create this text file with vba

    We use bartender to create labels and I need this output in a text file. The header is code to run and I know how to handle the characters in vba.
    The sample below is ~ delineated


    This is a sample output needed.

    Code:
    %BTW%C:\PROGRA~2\Seagull\BARTEN~1\BarTend.exe /AF="\\F99-HyperV-TS1\Bartender\Tpl\WHSE ITEM.btw"/P /X /D /DD
    %END%
    1~VA0764~fesl~99-Inv~01-A-01~MSI VLV, 2'' X 2''1502, STD HI-TEMP, W/ AIR ACTUATOR~GC_100~~0~~1~0
    1~VA0764~fesl~99-Inv~01-A-01~MSI VLV, 2'' X 2''1502, STD HI-TEMP, W/ AIR ACTUATOR~GC_101~~0~~1~0
    My main question is: If I have all the values in a form, how can I export a text file [.txt] that takes this form? I may be able to work around to comma delineated.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    1st build the export SPEC manually (the delimiters)...File export, Select the table, or query to export the data, choose text, then ADVANCED (button in bottom left corner of dialog box)
    Set your delimiters, etc and SAVE THE SPEC NAME.

    From then on, use the Transfertext command.

    DoCmd.TransferText acExportDelim, SPECNAME, Qry, FileName, True

  3. #3
    Fairlane is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    13
    How do I get this string appended to the beginning?
    Code:
    %BTW%/AF="\\F99-HyperV-TS1\Bartender\Tpl\WHSE ITEM.btw"/R=3/PRN="\\HV-AX-FILE-SERV\Printronix T5204r - PGL" /P /D="<Trigger File Name>" /DD
    %END%

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It depends...

    * Once you have created the text file, you can open it and manually paste it in at the top.

    * If the data (label info) is in tables and you use DoCmd.TransferText, you can use VBA to open and edit the text file using FSO.

    * If you use VBA to open a query to output the data (records), you would generate and print the string first, then loop through the records of the query, editing the record (the tilde or commas) before printing the record to the text file.

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Instead of TRANSFERTEXT to the final file, export it to BODY.txt
    Put your code in a file called HEADER.txt

    After the transfer step, the next step is to run a Batch file to assemble the two.
    call shell("C:\folder\assemble.bat")

    assemble.bat contains:
    COPY header.txt + body.txt FINALFILE.TXT

    This will produce your final file.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 07-09-2014, 12:43 PM
  2. Replies: 6
    Last Post: 11-08-2013, 11:18 AM
  3. Replies: 7
    Last Post: 06-06-2013, 10:32 AM
  4. Replies: 2
    Last Post: 12-27-2012, 09:37 AM
  5. Replies: 3
    Last Post: 07-30-2012, 02:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums