+ Reply to Thread
Results 1 to 4 of 4

Trying to Add Page Numbers to Full Image Footer with VBA

  1. #1
    Registered User
    Join Date
    10-30-2019
    Location
    Bistrita, Romania
    MS-Off Ver
    2013
    Posts
    113

    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
    Show your appreciation - click ★ Add reputation!

  2. #2
    Registered User
    Join Date
    10-30-2019
    Location
    Bistrita, Romania
    MS-Off Ver
    2013
    Posts
    113

    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,174

    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
    Registered User
    Join Date
    10-30-2019
    Location
    Bistrita, Romania
    MS-Off Ver
    2013
    Posts
    113

    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)

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