×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Write to text file with SolidWorks Macro

Write to text file with SolidWorks Macro

Write to text file with SolidWorks Macro

(OP)
I want to write different user inputs to a text file using a solidworks macro without writing over what is already there. Below is the code i have that writes over what is currently in the text file. Does anyone know how i can append the text without writing over it? I also want to record the "last saved by" infomation in the text file. How may i do that?

Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("C:\Users\Rn\Documents\testfile.txt", True)
a.WriteLine ("This is a test.")
a.WriteLine (gUSOutsideDia & vbTab & gUSBaseCircle)
a.Close

I have searched through the API help but can't seem to find anything.

Any help would be great!

RE: Write to text file with SolidWorks Macro

This is Microsoft Scripting functionality.  Google for CreateTextFile and you'll find loads of usage and examples.

-handleman, CSWP (The new, easy test)

RE: Write to text file with SolidWorks Macro

(OP)
Ok, I have the code fixed that that it does not write over other text and thank you very much for your help but how would i write the last saved information to the file too?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources