Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Oct 2002
    Location
    Portland, Maine, USA
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't Delete Temporary File (VBA Word 97)

    I am FTPing a file to a temporary file in the user's temp directory. I then InsertFile to put the text into a new document. If I then go to delete the temp file, I can't because the file is in use. This behavior occurs in straight Word (i.e. w/o using VBA) too. I tried to delete the file in the Document_Close event, but the file hasn't been released by that time.

    Any suggestions for a workaround?

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can't Delete Temporary File (VBA Word 97)

    Just a hunch: save the host file first, then try to delete the insertfile.

    You may have to close the host file first.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    New Lounger
    Join Date
    Oct 2002
    Location
    Portland, Maine, USA
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can't Delete Temporary File (VBA Word 97)

    I haven't tried that, but I really didn't want to save the document; the general intent here is to present it to the user who can decide to print it or save it.

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Can't Delete Temporary File (VBA Word 97)

    You could try capturing the content with copy and then paste it (although you'd probably have to open the temporary file along the way to do it).

    Not so tidy but at least it shouldn't link to the original file.
    Beryl M


  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can't Delete Temporary File (VBA Word 97)

    Word/Windows not releasing file handles has been a problem in every version of Word I've ever used.
    Sometimes, one is stuck and has to close word, then delete the file manually.
    Sometines, you have to find what process is hanging on to th handle (perhaps the FTOP software) and delete the process.
    In the worst case, you need to reboot.

  6. #6
    New Lounger
    Join Date
    Oct 2002
    Location
    Portland, Maine, USA
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can't Delete Temporary File (VBA Word 97)

    I sort of figured that. Clearly the FTP is not leaving the file open; the process is long gone at this point (and, as I said, this happens on any insertfile even w/o VBA code involved).

    I worked around the problem by opening the file with a FileSystemObject, and reading through it myself. I stuffed the data into the open document, closed the file, and deleted it. No problem. Just not fast or elegant.

Posting Permissions

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