Header and Footer Macro

  • Thread starter dhuang via OfficeKB.com
  • Start date
D

dhuang via OfficeKB.com

Hi!

I created a Macro that inserts the path file, name, and date but I want to
automate the authors name in their too. I remember someone inserting a
msgbox that allowed the author to put in his/her name and it would show in
the footer. As of right now this is what the Macro looks like:

How do I also insert the authors name?

Sub Traveler_Chart()
'
' Traveler_Chart Macro
' Macro recorded 10/31/2005 by David Huang 6-8395
'

'
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = "&D"
.LeftFooter = "" & Chr(10) & "&D&T"
.CenterFooter = ""
.RightFooter = "&Z&F"
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
End Sub
 
D

Dave O

You'd need to add a few lines of code at the top, something like this:

Dim UserName As String

Do Until UserName <> ""
UserName = InputBox("Please enter your name: ", "INPUT REQUIRED")
Loop

and then change one of the footer lines (.LeftFooter, .CenterFooter,
..RightFooter) like this:
..RightFooter = "&Z&F" & " " & UserName
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top