Results 1 to 2 of 2

Thread: how do i this???

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    157
    i am trying to create a program in vb which inputs some text in a word document. What i want to do is some how delete eveything that is on page 2 onwards, leaving only the contents of page 1 in that document.
    I have tried to use the macro in the word. but there is no way of doing this as i only have an option to select all.
    any suggestions ????

  2. #2
    Addicted Member Shrog's Avatar
    Join Date
    Aug 1999
    Location
    Darkest Africa
    Posts
    186
    Yes, here's a suggestion:
    Record a macro. Do what you want to do manually. Stop recording and look at the recorded code.

    To do what you want to do, Record a macro (Macro1).
    1) Press Ctrl + Home to go to the very top of the doc.
    2) Press Ctrl + PgDown to go to the start of the next page (Page 2).
    3) Press Shift + Ctrl + End to select everything to the end of the document.
    4) Press Delete to delete the selection.
    Stop Recording. Go to macros and "Edit" the macro that you have just recorded. The coding that you see will look something like this:
    Code:
        Selection.HomeKey Unit:=wdStory
        Application.Browser.Next
        Selection.EndKey Unit:=wdStory, Extend:=wdExtend
        Selection.Delete Unit:=wdCharacter, Count:=1

    Hope this helps.
    Shrog

    VB6 Ent SP5
    Win2000

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width