Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemObject: textfile contents erased

Status
Not open for further replies.

zimGirl

Geotechnical
Joined
Jul 22, 2004
Messages
30
Location
CA
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?
 
Are you closing the document first?

"Everybody is ignorant, only on different subjects." — Will Rogers
 
No I am not, how do I do close the document?
 
from your code, it would be...

a.close

"Everybody is ignorant, only on different subjects." — Will Rogers
 
hey borgunit,
Thanks for the help, worked great!!!
I had to close both the stream and the file
Code:
a.Close
Close #varFileNum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top