Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8490987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:17:07+00:00 2026-06-10T22:17:07+00:00

This is giving me headaches. I have a Word macro that is pretty huge.

  • 0

This is giving me headaches.
I have a Word macro that is pretty huge.
And at a certain point I have to change the header and format of the pages.

Hence I insert a break at this point

Selection.InsertBreak Type:=wdSectionBreakContinuous

change to landscape/horizontal format (cause the images have also this format)

    WordBasic.TogglePortrait Tab:=3, PaperSize:=0, TopMargin:="2.5", _
    BottomMargin:="2.5", LeftMargin:="2", RightMargin:="2.5", Gutter:="0", _
    PageWidth:="29.7", PageHeight:="21", Orientation:=1, FirstPage:=0, _
    OtherPages:=0, VertAlign:=0, ApplyPropsTo:=0, FacingPages:=0, _
    HeaderDistance:="1.25", FooterDistance:="1.25", SectionStart:=0, _
    OddAndEvenPages:=0, DifferentFirstPage:=0, Endnotes:=0, LineNum:=0, _
    StartingNum:=1, FromText:=wdAutoPosition, CountBy:=0, NumMode:=0, _
    TwoOnOne:=0, GutterPosition:=0, LayoutMode:=0, CharsLine:=41, LinesPage:= _
    39, CharPitch:=220, LinePitch:=360, DocFontName:="+Textkörper", _
    DocFontSize:=11, PageColumns:=1, TextFlow:=0, FirstPageOnLeft:=0, _
    SectionType:=1, FolioPrint:=0, ReverseFolio:=0, FolioPages:=1

enter the header

ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

the pages before shouldn’t be changed so unlink the header formation with the previous

Selection.HeaderFooter.LinkToPrevious = False

Jump out of the header go to the last page = the first page of the new section
This needs to be done otherwise I am in the header of the previous section due to the above command. (Dont know why it jumps into the last header) and jump into the correct header

ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.EndKey unit:=wdStory
ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

Select the whole header and delete it

Selection.WholeStory
Selection.Delete

Everything works fine if i set a breakpoint after changing to horizontal format means first time I jump into the header or at an earlier point of the above listed. But this is the last possible one.

Without the breakpoint instead of deleting only the header of the last page also the headers of the previous section are deleted.

I don’t know why this happens or how to prevent it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:17:08+00:00Added an answer on June 10, 2026 at 10:17 pm

    Ok I figured out how to do it.
    I already thought that it has something to do with the runtime and that some events couldn’t be executed in time.

    so i wrote a loop with doevents

    For u = 1 To 1000000
    DoEvents
    Next u
    

    This is too much I know but it works 😉

    edit:
    Actually 2 times is enough no need for 1000000 I just wanted to be sure in the beginning 😀

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is giving me a headache. I have this link query here that grabs
This issue is giving me serious headaches, I don't have a clue what's going
I have a school assignment that that is giving me and my friends headaches...
I have this mysql query (evolving two tables : Users and Files ) that's
This problem is giving me a real headache. I have two tables in my
I have a legacy database with a pretty evil design that I need to
This is giving me quite some headache. I have an page-tab-application, where DB-interaction uses
This has been giving me a headache for about two days now! I have
Well this is supposed to be a simple one but have been giving me
I have project that is giving me some headache and i think its because

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.