?
Solved

Moving and Deleting files in Access 2007

Posted on 2009-03-30
6
Medium Priority
?
198 Views
Last Modified: 2013-11-27
I have a form which I am viewing pdf files in a web browser.  I have 2 text boxes on the form which hold the current filename and path and another which will hold the newname and path.  Using the FileSystemObject I want to copy the file to the new location and then delete the source file.  The problem is that because the source file is being viewing in the web browser it throws a run-time 70, Permission Denied error.  Pointing the browser to something else i.e. another pdf or webpage before fso.deletefile  does not work to release the current file for deletion.  Any suggestions?
Forms!frmMyForm!WebBrowser.Navigate2(CurrentFilePath)
fso.CopyFile(CurrentFilePath, NewFilePath)
If fso.FileExists(NewFilePath) then
Forms!frmMyForm!WebBrowser.Navigate2(NewFilePath)
DoEvents
fso.DeleteFile(CurrentFilePath)
End If

Open in new window

0
Comment
Question by:DMC14319
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 75
ID: 24024009
FSO CopyFile should copy the file even if it is open ... it does for Access MDB's - because I just finished an entire app for automated backup based on the FSO.

Are you sure the error is not occurring on
fso.DeleteFile(CurrentFilePath)

?

mx
0
 

Author Comment

by:DMC14319
ID: 24024055
Yes the error is occuring while attempting to delete the file.  I have tried a number of things to slow or halt the code to make sure the browser unloads the file before the fso.deletefile but with no luck.  I have explored the "navigatecomplete2" without any luck also.
0
 
LVL 75
ID: 24024110
Humm.  Well, I had a similar issue in part of the backup routine - during the Compact and Repair process ... wherein I was using Shell to execute an Access command line to do the C&R - in a loop (about 20 mdb's). BUT ... I did not want to start the next C&R until the previous one completed.  So, I ended up using ShellWait - found here:

http://www.mvps.org/access/api/api0004.htm

That immediately solved that problem.  Maybe there is some way to use this to determine when the copy process completes.  Or, what about killing the browser task first?

I don't completely get what you are trying to do?  The browser has a PDF open - but you are trying to  copy it to a new location?

mx
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:DMC14319
ID: 24024154
Yes the users need to view the pdf first to make sure they have to correct file before moving it to a new location.  Once the file has been renamed and copied to a new location they need to delete the original file.  I will look into killing the browser task.
0
 
LVL 75
ID: 24024270
" I will look into killing the browser task."

ok ... so, you have the browser control on a form, right?

I'm thinking then that you could execute something like

' some code

Set oBrowserControl = Nothing   ' set the browser instance to nothing

' more code

oBrowserControl  would be the name of the object variable assigned to the browser control.

BUT ... I don't know if that would really 'kill' the instance of the browser in Task Manager - easy to try however.   Plus ... wouldn't this be annoying to the user ?

mx
0
 

Accepted Solution

by:
DMC14319 earned 0 total points
ID: 24043961
Couldn't find a suitable solution for this problem.  The workaround was to make a local temporary copy of the file and viewing the temp copy in the browser control.  Therefore the file system object was free to move, copy or delete the source file without locking issues.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question