Solved

Moving and Deleting files in Access 2007

Posted on 2009-03-30
6
191 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to let a Yes/No switch select a One record from the displayed record set? 10 58
Format a text field as percent 12 53
Menus 6 51
Access Need to add combo box to sub form 10 47
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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 …

737 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