"SaveAs" Generates error on shared drive

  • Thread starter Thread starter RWN
  • Start date Start date
R

RWN

XL'03.
Upon conversion from '97->'03 I have a template macro that's generating an error.

The macro changes the filename and when it hits the "SaveAs" statement in the following;

Application.DispalyAlerts = False
ThisWorkbook.Saveas OutDir & OutFile

Application.DispalyAlerts = False

...it generates a " cannot access filename" error.

This only happens when the output directory ("Outdir") is on a shared drive and the user
has closed and re-opened the file.
In other words, the 1st time the template is opened, data updated and macro executed
(which can be multiple times) all is well.
If the user then closes the (newly named) file and later re-opens it, does updates and
attempts to run the macro, it generates the error.

I'm assuming something is different in '03?
 
you can't use SaveAs and save the file with its own name, which is what
happens if you close & then re-open it.
A SaveAs will try to write over an existing file. If this ios the file
that's open, then the O/S locks it. Either use SAVE or make sure that the
filename used by the SaceAs isn't the name of an open workbook.
 
Thanks Patrick.

Strange that it worked using '97 and works fine in '03 *except* where the directory is on
a shared drive.
However, your note made me change my logic to check if the file already exists and, if so,
use a "Save" command.

At the end of the day it works.

Again, thanks for the hint.
 

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

Back
Top