Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Error When using ActiveWorkBook.SaveAs in Excel

I am trying to save an Excel workbook (that has a digital signature
applied if it makes any difference) in Excel 2003 SP2 via VBA using
the ActiveWorkbook.SaveAs command, however I get the follwoing error:

Microsoft Office Excel cannot access the file 'C:\Documents and
Settings\user\Desktop'. There are several possible reasons:
- The file name or path does not exist.
- The file is being used by another program.
- The workbook you are trying to save has the same name as a
currently open workbook.

This is my code residing in the ThisWorkBook module in VBA:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

[Run some other code........................]

Dim fname As Variant
fname = Application.GetSaveAsFilename(FileFilter:="Save File As
(*.xls),*.xls", Title:="Save File As")
Application.DisplayAlerts = False
Application.EnableEvents = False

ActiveWorkbook.SaveAs fname

Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub

I checked, and none of the above reasons seem to be true.

I have tried/checked the following things to no avail:
- Removed any add-ins in Excel
- Harcoded the full path/filename
- Tried saving a blank excel file with that simple line of code.
- Tried Me.SaveAs or ThisWorkbook.SaveAs
- Made sure the full file name and path were less than 200 characters
- Tried saving to other locations
- Not using IRM for Excel/Office
- Tried reinstalling office and all updates.
- Tried instyalling the hotfixes from MS KB Articles 919635 and 913770

I dont beleive this is a coding issue as it only occurs on a couple of
PC's.

Anyone have any ideas on how to fix this problem?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Error When using ActiveWorkBook.SaveAs in Excel

I don't think it's a coding issue either becaue there doesnt appear to be
anything wrong with the code.

Have you checked the priveleges for the users who are having a problem, are
they allowed to save to the desktop?

Mike

"Anthony" wrote:

I am trying to save an Excel workbook (that has a digital signature
applied if it makes any difference) in Excel 2003 SP2 via VBA using
the ActiveWorkbook.SaveAs command, however I get the follwoing error:

Microsoft Office Excel cannot access the file 'C:\Documents and
Settings\user\Desktop'. There are several possible reasons:
- The file name or path does not exist.
- The file is being used by another program.
- The workbook you are trying to save has the same name as a
currently open workbook.

This is my code residing in the ThisWorkBook module in VBA:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

[Run some other code........................]

Dim fname As Variant
fname = Application.GetSaveAsFilename(FileFilter:="Save File As
(*.xls),*.xls", Title:="Save File As")
Application.DisplayAlerts = False
Application.EnableEvents = False

ActiveWorkbook.SaveAs fname

Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub

I checked, and none of the above reasons seem to be true.

I have tried/checked the following things to no avail:
- Removed any add-ins in Excel
- Harcoded the full path/filename
- Tried saving a blank excel file with that simple line of code.
- Tried Me.SaveAs or ThisWorkbook.SaveAs
- Made sure the full file name and path were less than 200 characters
- Tried saving to other locations
- Not using IRM for Excel/Office
- Tried reinstalling office and all updates.
- Tried instyalling the hotfixes from MS KB Articles 919635 and 913770

I dont beleive this is a coding issue as it only occurs on a couple of
PC's.

Anyone have any ideas on how to fix this problem?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Error When using ActiveWorkBook.SaveAs in Excel

I do not understand your logic he

The Workbook_BeforeSave event occurs due to a "Save" command that HAS BEEN
ISSUED. This event enables to insert some code right before the saving is
committed. In your code, you can do something, such as check some
conditions. Then you can decide whether you wna the saving go ahead or
cancel it. So, I think, the code you show (after "[Run some other code...])
does not make sense: it just does what Excel would do after the event
handling procedure, since you did not cancel it.

So, unless the [Run some other code...] part results in some condition that
you have to cancel the saving, you do not need the last portion of the code,
just let Excel finish the saving.

Of course the code could make sure only when the the Workbook where the
Workbook_BeforeSave event associated to is not the ActiveWorkBook, whoch you
try to save in the event handler. That is you have multiple Workbooks open
and somehow your code or Excel is to save a non-active Workbook which
triggers the event, in which you want to save ActiveWorkbook.

I just wondering, if the Workbook that raises the BeforeSave event is the
ActiveWorkbook, shouldn't you fall into a dead loop: you/user do something
to start save it-BeforeSave fires-your code in BefreSave handler hijack
the saving and tries to save it-another BeforeSave even fires-your code
runs again, and a new SaveAs command called-BeforeSave fires-....



"Anthony" wrote in message
oups.com...
I am trying to save an Excel workbook (that has a digital signature
applied if it makes any difference) in Excel 2003 SP2 via VBA using
the ActiveWorkbook.SaveAs command, however I get the follwoing error:

Microsoft Office Excel cannot access the file 'C:\Documents and
Settings\user\Desktop'. There are several possible reasons:
- The file name or path does not exist.
- The file is being used by another program.
- The workbook you are trying to save has the same name as a
currently open workbook.

This is my code residing in the ThisWorkBook module in VBA:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

[Run some other code........................]

Dim fname As Variant
fname = Application.GetSaveAsFilename(FileFilter:="Save File As
(*.xls),*.xls", Title:="Save File As")
Application.DisplayAlerts = False
Application.EnableEvents = False

ActiveWorkbook.SaveAs fname

Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub

I checked, and none of the above reasons seem to be true.

I have tried/checked the following things to no avail:
- Removed any add-ins in Excel
- Harcoded the full path/filename
- Tried saving a blank excel file with that simple line of code.
- Tried Me.SaveAs or ThisWorkbook.SaveAs
- Made sure the full file name and path were less than 200 characters
- Tried saving to other locations
- Not using IRM for Excel/Office
- Tried reinstalling office and all updates.
- Tried instyalling the hotfixes from MS KB Articles 919635 and 913770

I dont beleive this is a coding issue as it only occurs on a couple of
PC's.

Anyone have any ideas on how to fix this problem?



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
ActiveWorkbook.SaveAs Returns BHatMJ Excel Programming 3 May 19th 07 02:31 AM
ActiveWorkbook.SaveAs Problem SowBelly Excel Programming 4 August 4th 04 10:58 PM
activeworkbook.saveas J Silver Excel Programming 0 June 25th 04 09:01 PM
Error on ActiveWorkbook.SaveAs method cruisy Excel Programming 3 May 17th 04 08:40 AM
Error on ActiveWorkbook.SaveAs method Tim Zych[_8_] Excel Programming 0 May 17th 04 06:33 AM


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

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

About Us

"It's about Microsoft Excel"