Consulting

Results 1 to 4 of 4

Thread: Solved: Syntax to "print in header"

  1. #1

    Solved: Syntax to "print in header"

    I know the code to put into the BeforePrint event handler to name a workbook the "filename" is:

    Worksheets("Sheet1").PageSetup.LeftHeader = ActiveWorkbook.FullName

    Instead I'm trying to put a cell content into the header off of worksheet "info", cell number C7

    Worksheets("HAHA Letter").PageSetup.LeftHeader = Worksheets("Info").C7

    Now I know that's not it...what would the syntax be?

  2. #2
    Forget it guys....I got it and it'll never work. It works normally, but I wanted it to print the headers when I printed to PDFs, and for some reason it doesn't pick it up.....unless anybody knows special code for THAT. What worked was....


    [VBA]
    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    ' inserts the same header/footer in all worksheets
    Dim ws As Worksheet
    Application.ScreenUpdating = False
    For Each ws In ActiveWorkbook.Worksheets
    Application.StatusBar = "Changing header/footer in " & ws.Name
    With ws.PageSetup
    .LeftHeader = Worksheets("Info").Range("C7").Text
    .CenterHeader = "Loan 1 " & Worksheets("Info").Range("C23").Text
    .RightHeader = "Loan 2 " & Worksheets("Info").Range("C33").Text
    End With
    Next ws
    Set ws = Nothing
    Application.StatusBar = False
    End Sub
    [/VBA]

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Why don't you insert headings into the sheets when you open the workbook, using the workbook open event?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    OMG!

    I didn't think about that...it's works brilliantly!

    Thank you thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •