urgent. need help on programming the default save button

  • Thread starter Thread starter shirley
  • Start date Start date
S

shirley

i want to change the color of my excel data when the default save butto
is clicked. how do i do so? i also want to change the color of my dat
just before the workbook is closed. how shld i do it? i have the cod
below, but they do not work.

Sub Workbook_beforeClose()

Dim Msg, Style, Title, Response
Msg = "Are you sure you want to exit? No changes are allowed afte
closing of the workbook."

Style = vbYesNo + vbQuestion
Title = "Important!"

If MsgBox(Msg, Style, Title) = vbYes Then
save

Else: End If

End Sub

Private Sub save()

If ThisWorkbook.save = True Then

ActiveSheet.Unprotect password:="1234"

ActiveSheet.Cells.Font.Color = RGB(0, 0, 0)

ActiveSheet.Cells.EntireRow.Locked = True
ThisWorkbook.save = True

ActiveSheet.Protect _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
password:="1234"

Else: End If

End Su
 
Hi
you may use the workbook event 'BeforeSave' for this as you currently
trigger your macro only on closing the workbook.
 
Back
Top