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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FIle i/o runtime error 52

Status
Not open for further replies.

mkiski

Technical User
Joined
Dec 5, 2004
Messages
1
Location
US
I have a simple VB6 program which opens an ASCII text file, writes some data, closes the text file. Then a MS word template is opened and data is entered via bookmarks. The Word document is saved and then closed. Next another ASCII text file is opened and writen to and then closed.

All of this works fine the first time through the program, but when the user tries to run the program again - runtime error 52 pops up.

Any suggestions?
 
This error means that you have tried to open a file with an invalid file name or that you have tried to use the VB file # without closing it properly after its first use.

If the program is being completely closed after its first run then it's probably a file name issue. If the process is being rerun from within the same instance of the program it's more likely that the file # needs to be released properly. Try using the FreeFile function to obtain the file number rather than using a fixed value or recode the whole thing to use the FileSystemObject which doesn't use file numbers.


Bob Boffin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top