PC Review


Reply
Thread Tools Rate Thread

Beforesave - Save copy on my desktop

 
 
J.W. Aldridge
Guest
Posts: n/a
 
      26th Sep 2007
Hi.

I have this code that i was running "beforeclose", however I adjusted
it to try to make it a "beforesave" code however, it doesnt work. No
error messages, but when i check my desktop, its not there.


Any advice?


Sub ThisWorkbook_BeforeSave(ByVal SaveAsUI As Boolean, ByRef Cancel As
Boolean)
Application.DisplayAlerts = False
Set WshShell = CreateObject("WScript.Shell")
ThisWorkbook.SaveAs Filename:=WshShell.SpecialFolders("Desktop") &
"\" & ThisWorkbook.Name
Application.DisplayAlerts = True
End Sub

 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      26th Sep 2007
Are you sure you want SaveAs rather than SaveCopyAs? Also, you should
disable events before doing the save -- otherwise you'll loop.

Sub ThisWorkbook_BeforeSave(ByVal SaveAsUI As Boolean, _
ByRef Cancel As Boolean)
Dim FName As String
On Error GoTo EXIT_SUB:
Application.EnableEvents = False
Application.DisplayAlerts = False
Set WshShell = CreateObject("WScript.Shell")
FName = WshShell.SpecialFolders("Desktop") & _
"\" & ThisWorkbook.Name
ThisWorkbook.SaveCopyAs Filename:=FName
EXIT_SUB:
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"J.W. Aldridge" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi.
>
> I have this code that i was running "beforeclose", however I adjusted
> it to try to make it a "beforesave" code however, it doesnt work. No
> error messages, but when i check my desktop, its not there.
>
>
> Any advice?
>
>
> Sub ThisWorkbook_BeforeSave(ByVal SaveAsUI As Boolean, ByRef Cancel As
> Boolean)
> Application.DisplayAlerts = False
> Set WshShell = CreateObject("WScript.Shell")
> ThisWorkbook.SaveAs Filename:=WshShell.SpecialFolders("Desktop") &
> "\" & ThisWorkbook.Name
> Application.DisplayAlerts = True
> End Sub
>


 
Reply With Quote
 
J.W. Aldridge
Guest
Posts: n/a
 
      26th Sep 2007
WOW....The Legend Himself???
(Man, I am honored!)


Yes, I believe Save a copy as is what I am trying to do.
Would that change the code recommended?


 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      26th Sep 2007
It shouldn't make a difference in the code whether you use SaveAs or
SaveCopyAs.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"J.W. Aldridge" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> WOW....The Legend Himself???
> (Man, I am honored!)
>
>
> Yes, I believe Save a copy as is what I am trying to do.
> Would that change the code recommended?
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use Workbook BeforeSave Event to Save Copy to Different Location RyanH Microsoft Excel Programming 9 23rd Oct 2008 07:48 PM
Save and Save as replaced by Update and Save Copy As =?Utf-8?B?bW9jY28wMg==?= Microsoft Word Document Management 2 19th Sep 2007 11:38 PM
Save method and BeforeSave event mikelee101@hotmail.com Microsoft Excel Programming 1 15th Jul 2005 04:58 AM
Detecting Save vs SaveAs in BeforeSave =?Utf-8?B?QWFyb24=?= Microsoft Excel Programming 2 3rd Jun 2004 11:16 AM
BeforeSave sub won't save another workbook when triggered by another event sub Brad Yundt Microsoft Excel Programming 1 3rd Jun 2004 03:12 AM


Features
 

Advertising
 

Newsgroups
 


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