Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RWN RWN is offline
external usenet poster
 
Posts: 104
Default "SaveAs" Generates error on shared drive

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?

--
Regards;
Rob
------------------------------------------------------------------------


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default "SaveAs" Generates error on shared drive

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.

"RWN" wrote:

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?

--
Regards;
Rob
------------------------------------------------------------------------



  #3   Report Post  
Posted to microsoft.public.excel.programming
RWN RWN is offline
external usenet poster
 
Posts: 104
Default "SaveAs" Generates error on shared drive

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.
--
Regards;
Rob
------------------------------------------------------------------------
"Patrick Molloy" wrote in message
...
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.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"FIND" generates "Type mismatch" error quartz[_2_] Excel Programming 5 November 16th 04 03:29 PM
error number to determine if shared file is open on "this" machine mark kubicki Excel Programming 1 June 22nd 04 09:48 PM
When is "?" really a "?" (.SaveAs with Chinese chars) Nick Cranham Excel Programming 0 February 13th 04 11:01 AM
SaveAs "subscript out of range" error (COM - SOAP) Matthia Excel Programming 0 July 11th 03 07:01 AM
SaveAs "subscript out of range" error (COM - SOAP) jaf Excel Programming 0 July 10th 03 07:59 PM


All times are GMT +1. The time now is 02:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"