Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default SAVE AS HELP

I am looking to trigger an event when a user selects save as.
I have a template file with raw data that is manipulated on the overview
sheet. I would like to remove the raw data tab when the save as is selected
in order to make the file smaller, leaving the template intact..
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default SAVE AS HELP

This sounds dangerous to the user to me. Maybe they're not done with that sheet
yet.

I wouldn't do this, but if you want:

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
On Error Resume Next
Application.DisplayAlerts = False
Me.Worksheets("raw data").Delete
Application.DisplayAlerts = True
On Error GoTo 0
End Sub

This is a workbook event and it goes in the ThisWorkbook module of that
workbook's project.

Instead I'd provide a dedicated macro that would accomplish the same thing.
Then tell the user to run that macro when they're finished with that sheet.

Or even ask before deleting???

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

Dim resp As Long
Dim wks As Worksheet
Dim wksName As String

wksName = "Raw Data"

Set wks = Nothing
On Error Resume Next
Set wks = Worksheets(wksName)
On Error GoTo 0

If wks Is Nothing Then
'already gone, do nothing
Else
resp = MsgBox(Prompt:="Want to delete " & wksName, _
Buttons:=vbYesNo)

If resp = vbYes Then
On Error Resume Next
Application.DisplayAlerts = False
Me.Worksheets(wksName).Delete
Application.DisplayAlerts = True
On Error GoTo 0
End If
End If
End Sub


Rpettis31 wrote:

I am looking to trigger an event when a user selects save as.
I have a template file with raw data that is manipulated on the overview
sheet. I would like to remove the raw data tab when the save as is selected
in order to make the file smaller, leaving the template intact..


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default SAVE AS HELP

Thanks for the information, I decided to keep the Raw data as a seperate
file. So no need to delete.

Thanks
Robert

"Dave Peterson" wrote:

This sounds dangerous to the user to me. Maybe they're not done with that sheet
yet.

I wouldn't do this, but if you want:

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
On Error Resume Next
Application.DisplayAlerts = False
Me.Worksheets("raw data").Delete
Application.DisplayAlerts = True
On Error GoTo 0
End Sub

This is a workbook event and it goes in the ThisWorkbook module of that
workbook's project.

Instead I'd provide a dedicated macro that would accomplish the same thing.
Then tell the user to run that macro when they're finished with that sheet.

Or even ask before deleting???

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

Dim resp As Long
Dim wks As Worksheet
Dim wksName As String

wksName = "Raw Data"

Set wks = Nothing
On Error Resume Next
Set wks = Worksheets(wksName)
On Error GoTo 0

If wks Is Nothing Then
'already gone, do nothing
Else
resp = MsgBox(Prompt:="Want to delete " & wksName, _
Buttons:=vbYesNo)

If resp = vbYes Then
On Error Resume Next
Application.DisplayAlerts = False
Me.Worksheets(wksName).Delete
Application.DisplayAlerts = True
On Error GoTo 0
End If
End If
End Sub


Rpettis31 wrote:

I am looking to trigger an event when a user selects save as.
I have a template file with raw data that is manipulated on the overview
sheet. I would like to remove the raw data tab when the save as is selected
in order to make the file smaller, leaving the template intact..


--

Dave Peterson

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
Save, save as, page setup dimmed out in unprotected excel sheet? ccKeithJ Excel Discussion (Misc queries) 3 December 14th 07 07:07 PM
prompt user to save file as {desired_name} and save it to a variab GeneWan Excel Programming 1 January 5th 07 06:46 AM
Disable save, save as, but allow save via command button TimN Excel Programming 10 September 1st 06 07:05 PM
How to diasble save and save as menu but allow a save button hon123456 Excel Programming 1 June 12th 06 09:50 AM
Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use: harpscardiff[_10_] Excel Programming 8 November 10th 05 12:24 PM


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