You could digitally sign your workbook. I've never done this, but I think
excel's help describes the process.
Personally, I wouldn't want this in each workbook I use. It's redundant and
it'll make updates a real pain to catch up.
I'd use an addin that does the work. And I'd store this addin in my XLStart
folder. I'd name the workbook/addin "JDsUtils.xla".
If you want to try...
Start a new workbook
Put this in a general module:
Option Explicit
Public Const ToolBarName As String = "JD's Utilities"
Private Sub Aut
pen()
Call CreateMenubar
End Sub
Private Sub Auto_Close()
Call RemoveMenubar
End Sub
Private Sub RemoveMenubar()
On Error Resume Next
Application.CommandBars(ToolBarName).Delete
On Error GoTo 0
End Sub
Private Sub CreateMenubar()
Dim iCtr As Long
Dim MacNames As Variant
Dim CapNames As Variant
Dim TipText As Variant
Call RemoveMenubar
MacNames = Array("FixOneSheet", _
"FixAllSheets")
CapNames = Array("Add Headers to this sheet", _
"Add Headers to All Sheets")
TipText = Array("Run this for just the activesheet", _
"Run this for all the sheets")
With Application.CommandBars.Add
.Name = ToolBarName
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating
For iCtr = LBound(MacNames) To UBound(MacNames)
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & MacNames(iCtr)
.Caption = CapNames(iCtr)
.Style = msoButtonCaption
.TooltipText = TipText(iCtr)
End With
Next iCtr
End With
End Sub
Private Sub FixOneSheet()
Call DoTheWork(ActiveSheet)
End Sub
Private Sub FixAllSheets()
Dim sh As Object
For Each sh In ActiveWorkbook.Sheets
Call DoTheWork(sh)
Next sh
End Sub
Private Sub DoTheWork(sh As Object)
'to include the path, you could use
'sh.parent.fullname
sh.PageSetup.RightHeader _
= sh.Parent.Name & " " & Format(Date, "dd mmmm yyyy")
End Sub
Then back to excel.
File|SaveAs
choose Addin
and store it in your XLStart folder.
Close excel and restart it.
Then open or create a new workbook and test it.
ps. If you decide you want to fiddle with the header, record a macro when you
change it manually. You may be able to pick out the pieces you need (like
font/font size) and included it in this code.
How do I add to the macro to also include the file name with three
spaces between the file name and the date?
Also, when I start this .xls file I get a warning about running macros
so can I somehow identify myself as the author of this macro and allow
it to run without the warning? If I can, how do I do that?
Or is there a better way to enter the file name and long date without
doing it manually?