Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Help Needed! VB Code to "Save As..."

Actually, this is a little more clear. You can keep the screen updating.
Switch your sheets before the If and switch them back after the End if.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False
If SaveAsUI Then
Application.Dialogs(xlDialogSaveAs).Show
Else
ThisWorkbook.Save
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Elkar" wrote in message
...
I have a workbook that I am requiring Macros to be activated in order to
use.
I've managed to do this by using the following code in the BeforeSave
event:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False
ActiveWorkbook.Unprotect ("password")
Worksheets("Warning").Visible = True
Worksheets("Time Sheet").Visible = False
Worksheets("Data Sheet").Visible = False
ActiveWorkbook.Protect ("password")
ActiveWorkbook.Save
Application.EnableEvents = True
ActiveWorkbook.Unprotect ("password")
Worksheets("Time Sheet").Visible = True
Worksheets("Data Sheet").Visible = True
Worksheets("Warning").Visible = False
ActiveWorkbook.Protect ("password")
Application.ScreenUpdating = True
ThisWorkbook.Saved = True
End Sub

This works great, except that the user can't use "Save As..." to change
the
filename. Even if I use the line Activeworkbook.SaveAs, it still only
saves
over the original filename. How can I modify this so that Save As will
work?

Any help is much appreciated. Thanks in advance!
Elkar



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 964
Default Help Needed! VB Code to "Save As..."

Excellent!!! This is exactly what I needed. Thank you so much!!
Elkar

"Jon Peltier" wrote:

Actually, this is a little more clear. You can keep the screen updating.
Switch your sheets before the If and switch them back after the End if.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False
If SaveAsUI Then
Application.Dialogs(xlDialogSaveAs).Show
Else
ThisWorkbook.Save
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Elkar" wrote in message
...
I have a workbook that I am requiring Macros to be activated in order to
use.
I've managed to do this by using the following code in the BeforeSave
event:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False
ActiveWorkbook.Unprotect ("password")
Worksheets("Warning").Visible = True
Worksheets("Time Sheet").Visible = False
Worksheets("Data Sheet").Visible = False
ActiveWorkbook.Protect ("password")
ActiveWorkbook.Save
Application.EnableEvents = True
ActiveWorkbook.Unprotect ("password")
Worksheets("Time Sheet").Visible = True
Worksheets("Data Sheet").Visible = True
Worksheets("Warning").Visible = False
ActiveWorkbook.Protect ("password")
Application.ScreenUpdating = True
ThisWorkbook.Saved = True
End Sub

This works great, except that the user can't use "Save As..." to change
the
filename. Even if I use the line Activeworkbook.SaveAs, it still only
saves
over the original filename. How can I modify this so that Save As will
work?

Any help is much appreciated. Thanks in advance!
Elkar




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
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 ronhansen Excel Discussion (Misc queries) 1 November 15th 09 09:33 PM
"CELL("FILENAME") NOT UPDATE AFTER "SAVE AS" ACTION yossie6 Excel Discussion (Misc queries) 1 June 16th 08 12:16 PM
"Save" and "Save As" options greyed out - "Save as Webpage" option Bill Excel Discussion (Misc queries) 0 January 16th 07 04:47 PM
Help Needed! VB Code to "Save As..." Jon Peltier Excel Programming 0 January 11th 07 10:32 PM
save and restore "Workbook Menu Bar" & "Cell" menus Jeff Higgins Excel Programming 2 February 14th 05 01:33 AM


All times are GMT +1. The time now is 04:11 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"