Results 1 to 8 of 8

VBA Code to Pass String into Page Header

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    Excel 365
    Posts
    129

    VBA Code to Pass String into Page Header

    I've got a template that I am trying to use for multiple reports. Depending on which macro gets run, I want it to put a string into the header so I know which report is generated. Here are the issues that I'm having:

    1. I use a picture in the center space of the header and eventhough I want my Report type text to be displayed in the middle of the page, I can't get the text to run ontop of the picture unless it is in the left header field.
    2. Since I have to use the left header field, I need to add spaces to the Header to Kick the Text into the center-ish place on the report, but VBA is not liking my " " designation.
    3. Finally, the code below works (minus the spacing being done correctly), however I can't get VBA to pass the variable into the header. Therefore, the code below just puts "HeaderName" into the header instead of "Annual Report"

    'start header
    Dim HeaderName As String
    HeaderName = "Annual Report"
    With ActiveSheet.PageSetup
    .DifferentFirstPageHeaderFooter = False
        .LeftHeader = "&""Arial,Bold""&11  & ""      "" & HeaderName &G"
        
    End With
    Any ideas?
    Last edited by jeffreybrown; 05-12-2020 at 02:32 PM. Reason: Please use code tags!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Repeating the header at the start of each page with the page number
    By Viswateja in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2017, 02:17 PM
  2. [SOLVED] Why does this code FIND the LAST string on the page?
    By CaptMac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-20-2016, 03:45 AM
  3. Trying to find & copy text string from page source code
    By LightingPop in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-16-2015, 09:24 PM
  4. Replies: 2
    Last Post: 10-21-2011, 04:13 AM
  5. Replies: 2
    Last Post: 01-16-2009, 05:24 PM
  6. [SOLVED] Can't insert a String Variable of Long Date into Page Header
    By Ronny Hamida in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2006, 12:45 PM
  7. Replies: 3
    Last Post: 03-29-2006, 12:50 PM

Tags for this Thread

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