• Using VBA to delete 1st line on each page… (2000 SP-3)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Using VBA to delete 1st line on each page… (2000 SP-3)

    Author
    Topic
    #408556

    Hello everyone…

    This is my first time trying to use VBA automation with Word… I have a old document that is over 400 pages… I want to write code to do the following:

    Go to top line of the first page of the document
    Select and/or delete the top line of the page
    Delete one more space (to move up the old second line to the first)
    Move to the next page
    Continue this process (looping) until the end of the document

    I’m so completely unfamiliar with Word’s objects and collections and I’ve tried searching VBA help but I’m not finding any answers…
    It seems like such a simple thing to do… It must be possible…
    Any help would be appreciated…

    thankyou

    Viewing 1 reply thread
    Author
    Replies
    • #863602

      Hi Alexya,

      This will be tricky. There’s no “page” object in Word VBA, because of how pagination is controlled (it involves the printer driver). The same document on two different machines might have slightly different pagination.

      In addition, as you move through a 400-page document, deleting items, the text will move “up”, and what was once at the top of a page might be at the bottom of the previous page.

      Are there manual page breaks in the document? Could you describe more specifically the reason you’re deleting the first line of every page? Even more helpful would be a few sample pages (replace with dummy text if the information is sensitive).

    • #863603

      Hi Alexya,

      This will be tricky. There’s no “page” object in Word VBA, because of how pagination is controlled (it involves the printer driver). The same document on two different machines might have slightly different pagination.

      In addition, as you move through a 400-page document, deleting items, the text will move “up”, and what was once at the top of a page might be at the bottom of the previous page.

      Are there manual page breaks in the document? Could you describe more specifically the reason you’re deleting the first line of every page? Even more helpful would be a few sample pages (replace with dummy text if the information is sensitive).

    Viewing 1 reply thread
    Reply To: Using VBA to delete 1st line on each page… (2000 SP-3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: