+ Reply to Thread
Results 1 to 3 of 3

Thread: Select all EXCEPT top line

  1. #1
    Forum Guru
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2010
    Posts
    1,502

    Select all EXCEPT top line

    I'm just starting with Word macros, so please bear with this basic question. I know how, via VBA, to select the whole document, but how do I select it all minus the very top line?
    Last edited by jomili; 02-10-2011 at 08:20 AM.

  2. #2
    Forum Contributor sauerj's Avatar
    Join Date
    11-11-2009
    Location
    Lafayette, IN
    MS-Off Ver
    Excel 2003
    Posts
    116

    Re: Select all EXCEPT top line

    Sub SeltLine2toEnd()
     With ActiveDocument
      .Paragraphs(1).Range.Select
      Selection.SetRange Start:=Selection.Start, _
         End:=.Paragraphs(.Paragraphs.Count).Range.End
      Selection.MoveStart unit:=wdLine, Count:=1
     End With
    End Sub
    1) There might be a simpler way, but the above works.
    2) If you don't already, use the OBJECT BROWSER (F2 w/ the Editor open) to help understand what commands you have available for the various objects (such as Document, Range, Selection). There are lots of various MOVE commands (methods) that move the start or end position of a selection. You'll find these in the BROWSER under the Selection and Range objects. Use the HELP to explain how these work.
    3) Careful using the WORD VB RECORDER on advanced stuff, it usually gives you erroneous code. But its a good starting point; just don't assume it is ok. ... regards, sauerj

  3. #3
    Forum Guru
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2010
    Posts
    1,502

    Re: Select all EXCEPT top line

    Thanks Saurej,

    The code you provided helped me fix my problem. Thanks for the pointers on using the Object Browser. I've done a few Excel macros, so already know the macro recorder is far from foolproof, but the warning is appreciated.

    Thanks,
    John

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0