Results 1 to 6 of 6
  1. #1
    PID69Loop Guest

    Default How to Write to a Text File from VBA

    I want to write to a text file from my VBA of SCADA software...
    Can anyone help to find sample code?

    Thanks in advance...

  2. #2
    Steve Guest

    Default code

    Here is a sample code for you
    -OPEN file for output.
    -Instead of the keyword 'Append' you can choose WRITE to overwrite the last file entry
    -The file type can also be .txt

    VBA code for text file

    Open "C:TestTESTFILE.CSV" For Append As #1
    Write #1, TestLine1, 234, moredata ' Write data.
    Write #1, TestLine2, Format(Now(), "m/d/yy h:m:s AMPM") ' Write data and timestamp
    Write #1, ' Write blank line.
    Close #1 ' Close file.


    Hope this helps.

    Steve

  3. #3
    pid69Loop Guest

    Thumbs up Thanks.

    Thanks Steve,

  4. #4
    HardDisk Guest

    Default

    Great time saver example code ...thanks.

  5. #5

    Default

    Oh My God! It worked for me. ... thank you.

  6. #6
    Benty99 Guest

    Default Write text file from VBA.....

    One of best and simple code...it shine...

    1-OPEN file for output.
    2-Instead of the keyword 'Append' you can choose WRITE to overwrite the last file entry
    3-The file type can also be .txt

    VBA code for text file

    Open "C:\MyFILE.CSV" For Append As #1
    Write #1, TestLine1, 234, moredata ' Write data.
    Write #1, TestLine2, Format(Now(), "m/d/yy h:m:s AMPM") ' Write data and timestamp
    Write #1, ' Write blank line.
    Close #1 ' Close file.
    Last edited by Benty99; November 19th, 2013 at 06:23 PM.

Similar Threads

  1. Text output value in QTP
    By AutoLady in forum Automation Applications & Software
    Replies: 7
    Last Post: October 23rd, 2010, 03:11 PM
  2. What is the file extension of the code file and object repository file in QTP?
    By BAT in forum Automation Applications & Software
    Replies: 3
    Last Post: October 23rd, 2010, 02:06 PM
  3. Software to transform file HEX to file with format C?
    By ken in forum Automation Applications & Software
    Replies: 1
    Last Post: November 17th, 2009, 05:39 PM
  4. Nothing happens when trying to open text file in VBA
    By saab in forum Programming Languages
    Replies: 1
    Last Post: August 14th, 2009, 01:22 PM
  5. vtext.dll (Text To Speech) not working in WXP with iFix?
    By Linda in forum Automation Applications & Software
    Replies: 3
    Last Post: April 6th, 2008, 10:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •