Results 1 to 2 of 2
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA delete file - error file access denied

    Hi ya - Word 97 VBA

    I have code which saves a word document in C:Temp
    formats/edits this file
    saves in a PDF format
    then does housekeeping & deletes 'kills' the doc file.

    With the old pc's the users are getting a run time error
    eg file/pemission denied.
    The reason being is the old slow pc has slow processing speed
    therefore the doc file is actually closed in Word, however is still open in Word's processes.

    The file is attempted to be deleted however its still open in word therefore its a file sharing restriction.
    ...because you cant delete a file if its open elsewhere.

    I thought I had resolved this issue by moving the 'kill' line of code further towards the end of the code to free up some time - however this didnt work.

    Is there anyway around this?
    Is there like a 'pause' syntax? which I could use for example pause for 5 secs until file is free.
    Any other suggestions would be much appreciated.

    Many thanks in advance - cheers Diana

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA delete file - error file access denied

    You could put the Kill commands in a separate procedure and then use the OnTime method to schedule this procedure to run some number of seconds after the first one ends.
    Legare Coleman

Posting Permissions

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