1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Word Macro: How to keep macro running until end of page is reached

Discussion in 'Business Applications' started by HowdeeDoodee, Jun 6, 2008.

Thread Status:
Not open for further replies.
  1. HowdeeDoodee

    HowdeeDoodee Thread Starter

    Aug 26, 2004
    How do you keep a macro running until you reach the end of a page? Currently I just hold down the control or Alt keys. I have long documents so holding down the Alt + whatever key is not always practical.

    Here is a sample macro. How do I make the macro run until the macro reaches (in this case) the top of the page?

    I think the "do until" feature is used in the code but I do not know the syntax for "do until".

    Sub DelimitBoldSentenceOnRightWithATab()
    Selection.Find.Font.Bold = True
    With Selection.Find
        .Text = "*"
        .Replacement.Text = ""
        .Forward = False
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.TypeText Text:=vbTab & vbTab
    Selection.MoveUp Unit:=wdParagraph, Count:=1, Extend:=wdExtend
    Selection.MoveLeft Unit:=wdCharacter, Count:=1
    Selection.TypeText Text:=vbTab & vbTab
    Selection.MoveLeft Unit:=wdCharacter, Count:=3
    End Sub
    Thank you in advance for your replies.
  2. Rollin_Again


    Sep 4, 2003
    You can evaluate the current page number using the following property:


    Just use a loop and have it execute while Selection.Information(wdActiveEndPageNumber) = 1

    Can you post your sample document?

  3. HowdeeDoodee

    HowdeeDoodee Thread Starter

    Aug 26, 2004
    Hi Rollin. Thank you for the reply. You have helped me before. Good to see you again.

    Here is only a tiny snippet of one of the documents. Most documents are 1400 - 1800 pages. The snippet below shows the document before I do any processing on it. In the processing sequences, I do the documents both from the bottom of the document up and from the top down (different documents and different macros of course). I would like basic strategy on where to put the loop since differnt macros are going to have different code.

    Thank you again for the response.
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/718978