Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Beforesave - Save copy on my desktop

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Beforesave - Save copy on my desktop

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" wrote in message
ups.com...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Beforesave - Save copy on my desktop

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?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Beforesave - Save copy on my desktop

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" wrote in message
ups.com...
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
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
Desktop Save Question Jenny B. Excel Discussion (Misc queries) 7 March 26th 08 01:49 AM
Save .xls as .txt In DeskTop Antonyo[_2_] Excel Programming 3 July 18th 05 01:52 PM
Save method and BeforeSave event [email protected] Excel Programming 1 July 15th 05 04:58 AM
Detecting Save vs SaveAs in BeforeSave Aaron[_9_] Excel Programming 2 June 3rd 04 11:16 AM
BeforeSave sub won't save another workbook when triggered by another event sub Brad Yundt Excel Programming 1 June 3rd 04 03:12 AM


All times are GMT +1. The time now is 06:17 PM.

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"