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.
1) There might be a simpler way, but the above works.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
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
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks