Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default Filename in Macro

When I go into VBA and save the macro is fine until I exit the excel file
and reopen it this is when the macro is back to 'excel file
name'!UnProtectAllSheets

Hi I have the following Macro in mt excel workbook.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Call ProtectAllSheets
Call PageSetUp
End Sub
Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Protect Password:="1257"
Next n
Application.ScreenUpdating = True
End Sub
Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Unprotect Password:="1257"
Next n
Application.ScreenUpdating = True
End Sub
Sub PageSetUp()
Dim SH1 As Object
Dim SH2 As Object
With ActiveWorkbook
Set SH1 = .Sheets("Relief Final Shifts")
Set SH2 = .Sheets("Shifts still to Cover")
End With
SH1.PageSetUp.RightFooter = "Relief Shifts " & Format(Now, "dd-mmm-yy")
SH2.PageSetUp.RightFooter = Format(Now, "dd-mmm-yy")
End Sub

this was working fine until I saved the excel file to a new name using save
as, now this original template file will not operate the macro
UnProtectAllSheets properly, when I go to view macro and run the macro in
coming up with the excel workbook name first and is unable to run macro until
I press alt + f11 then save it again in vba, this works until I exit the
excel file then i'm back to the beginning fault, anyone have any ideas what
might be wrong and how to rectify this.

Many thanks


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
Filename macro and a little more? kennected Excel Programming 4 March 17th 08 03:50 PM
how to name filename with date in macro Daniel M Excel Programming 1 November 20th 07 02:26 PM
filename in macro ynissel Excel Discussion (Misc queries) 7 June 12th 06 08:41 PM
Put Filename Variable in Macro David Excel Discussion (Misc queries) 4 December 27th 05 06:27 PM
Dynamic Filename From Macro Craig[_9_] Excel Programming 1 November 6th 03 06:36 PM


All times are GMT +1. The time now is 10:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"