+ Reply to Thread
Results 1 to 4 of 4

Trying to Add Page Numbers to Full Image Footer with VBA

  1. #1
    Forum Contributor
    Join Date
    10-30-2019
    Location
    Bistrita, Romania
    MS-Off Ver
    2019; 365
    Posts
    231

    Trying to Add Page Numbers to Full Image Footer with VBA

    Hello,

    At work I am using a UserForm to add image based headers and footers (H&F) to the active document. I created the UserForm in my personal.xlsb file so it's accessible everywhere.

    For this example though, I created a test macro in the attached file. The file already has the image H&F and for the 1st section I also added the page numbers to see how it should look like (adding page numbers is what I want to do).
    Also attached are the 4 images that are used as headers and footers for testing purposes (4 because 2 are for portrait and 2 for landscape pages).
    If you want to test the code, please make a folder named HeadFoot under C:\ and put the 4 images in there (the code grabs them from eg. C:\HeadFoot\EXFORUM Portrait SUS.png)

    I am trying to add page numbers (page 1 / 1 etc.) to footer right above the existing image (see section 1 of the attached file).
    The page numbers should go continuously, regardless of how many sections I have and which are not linked because landscape H&F image is different than portrait H&F image.

    I tried recording a macro, but when recording in Word the cassette cursor shows and I can't really do much - can't select image with mouse, can't select text with mouse etc.

    So I have trouble including a code like the one below into my already working UserForm code in order to show continuous page numbers in all sections like in section 1 of the attached file.

    This is the snippet that I normally use to add page numbers to current cursor position:
    Please Login or Register  to view this content.
    Could someone help me?
    Thanks in advance for your time.
    Attached Files Attached Files
    To show your appreciation
    Click ★ Add reputation!

  2. #2
    Forum Contributor
    Join Date
    10-30-2019
    Location
    Bistrita, Romania
    MS-Off Ver
    2019; 365
    Posts
    231

    Lightbulb Re: Trying to Add Page Numbers to Full Image Footer with VBA

    Upon more testing and trying various snippets in a Module, I finally managed to solve this myself.

    In case someone needs this, I attached the file with a working code.

    I encountered an annoying issue however.
    For some unknown reason, after accessing header and footer via VBA the document would switch to Draft View - no idea why
    Changing it once to PrintView did the trick up until I closed Header and Footer when it went back to Draft View.
    That's why the code ends in 2 snippets doing the same thing - switching from Draft View to Print View.

    Maybe there is still room to improve this code, so if someone knows how I'd really appreciate any tips.

    Thanks to all who put even as little time as required to read my post.
    Attached Files Attached Files

  3. #3
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Trying to Add Page Numbers to Full Image Footer with VBA

    Please Login or Register  to view this content.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    Forum Contributor
    Join Date
    10-30-2019
    Location
    Bistrita, Romania
    MS-Off Ver
    2019; 365
    Posts
    231

    Re: Trying to Add Page Numbers to Full Image Footer with VBA

    That is great, way better than mine.

    Thanks a lot!

+ 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. Merging Two VBA Codes - Insert XL Stored Image & Unique Last Page Footer
    By andydavidbrown in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-28-2019, 09:09 AM
  2. [SOLVED] Full (100%) page width footer
    By ArnolddG in forum Excel General
    Replies: 2
    Last Post: 01-03-2014, 07:40 AM
  3. Page numbers not in Header/Footer
    By rkemmerich in forum Excel General
    Replies: 2
    Last Post: 04-05-2013, 08:59 AM
  4. Get total pages per sheet and set page numbers in page footer by formula
    By Snoopy2003 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-13-2013, 04:00 PM
  5. Using Section Page Numbers and Document Page Numbers In Footer
    By janschepens in forum Word Formatting & General
    Replies: 2
    Last Post: 03-16-2012, 01:54 PM
  6. Background image Full page
    By rfanciulli in forum Excel General
    Replies: 1
    Last Post: 06-10-2011, 08:04 AM
  7. Page Numbers (Footer)
    By conks in forum Excel General
    Replies: 2
    Last Post: 02-23-2009, 09:37 AM

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