×
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

FileSystemObject: textfile contents erased

FileSystemObject: textfile contents erased

FileSystemObject: textfile contents erased

(OP)

CODE

Set fs = CreateObject("Scripting.FileSystemObject")

        Set f = fs.GetFile(dlgMain.FileName)                

        Set a = f.OpenAsTextStream(varFileNum)

Hey guys,

When I open a file as a textstream (Code above) and hit the (X) to close the form and
exit program before using it in the program (Not Graceful exit), It erases the text
in the file and I get a blank file left over. (same name)

Is there something I am not doing at the end. Why does it erase the text in the file?

RE: FileSystemObject: textfile contents erased

Are you closing the document first?

"Everybody is ignorant, only on different subjects." — Will Rogers

RE: FileSystemObject: textfile contents erased

(OP)
No I am not, how do I do close the document?

RE: FileSystemObject: textfile contents erased

from your code, it would be...

a.close

"Everybody is ignorant, only on different subjects." — Will Rogers

RE: FileSystemObject: textfile contents erased

(OP)
hey borgunit,
Thanks for the help, worked great!!!
I had to close both the stream and the file

CODE

a.Close
Close #varFileNum

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