+ Reply to Thread
Results 1 to 2 of 2

how to Use Before_Print macro to add a multiple line header

  1. #1
    Registered User
    Join Date
    08-27-2014
    Location
    Vancouver
    MS-Off Ver
    2013
    Posts
    1

    how to Use Before_Print macro to add a multiple line header

    Hi,

    I am trying to create a macro that add a multiple line header to all the pages of a worksheet before printing.
    I have written this code but it's not working.Please help

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    With ActiveSheet.PageSetup
    .DifferentFirstPageHeaderFooter = True
    .FirstPage.LeftHeader = "&""Times New Roman,Bold""&16 TEST" & Chr(10)_
    & "Times New Roman,Bold""&16TEST2" & Chr(10) _
    & "Times New Roman,Bold""&16TEST3"
    .LeftHeader = "&""Times New Roman,Bold""&12TEST4"
    End With
    End Sub

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: how to Use Before_Print macro to add a multiple line header

    Welcome to the Forum. For future reference, please enclose code in code tags. Thanks.

    When I ran your code, I got an error on the following portion:
    Please Login or Register  to view this content.
    When I deleted that out, it ran and put TEST4 at the top of the 2nd page. I would suggest starting over with recording a new macro that sets up your page like you want it, and then making the adjustments.
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. copy Before_print code into new workbook
    By rhodevans in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2013, 09:05 AM
  2. [SOLVED] Probably a simple question. on before_print for worksheets
    By rhodevans in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-29-2013, 07:29 PM
  3. Replies: 2
    Last Post: 10-13-2012, 03:30 AM
  4. VBA-Before_Print worked last week but now does not
    By Royzer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2012, 03:08 AM
  5. Ungroup selected worksheets after Before_Print event
    By clng in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-27-2010, 11:53 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1