Saving to Access Database

R

Red

All help is greatly appreciated, I can't work out whets wrong with the below
code. I'm trying to loop through all MPP files, open each and save it to an
Access Database. It runs fine for the first MPP but on the second I get the
following error:

"The file DBName & MPPFile cannot be deleted because it is open or being
used by another program"

Is this even the correct approach??


MPPFile = Dir(JobPath & J(i) & "\" & "*.MPP")
Do While MPPFile <> "" 'Start the loop
FileName = JobPath & J(i) & "\" & MPPFile
DBName = "<\\Hta-nt1\Project_plans\Project_Server.mdb>\"
FileOpen FileName, , , , , , , , , , , pjDoNotOpenPool
FileSaveAs DBName & MPPFile, , , , , , , , , "MSProject.MDB8"
MPPFile = Dir
Loop
 
T

Tomm

Just a wild guess code is running too fast.

Try
Dim x, y

x=FileOpen( FileName, , , , , , , , , , , pjDoNotOpenPool)

y=FileSaveAs( DBName & MPPFile, , , , , , , , , "MSProject.MDB8")

to ensure code is finished running before next step.
 
R

Red

I've tried slowing things down but still get the same error. Any other ideas
or maybe a different approach?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top