View Single Post
 
Old 03-28-2021, 02:36 PM
Guessed's Avatar
Guessed Guessed is online now Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,158
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Cendrinne

Think about VBA commands as basically a roadmap, zooming in to lower levels as you go. It is similar to saying Earth.Canada.Quebec.Montreal - each steps gives greater resolution. We can't just say Montreal because there are Montreal streets in cities all over the world.

Each vba command is part of a chain that provides context for the next command. Sections(1) tells you something but without the context preceding it we can only guess which Section was intended.

ActiveDocument.Sections(2).Paragraph(3) would be saying -> think of the active document, now in that document think of the second section, now in that section think of the third paragraph

Selection.Range.Sections(1).Range.Start is saying -> go to the current selection, then convert it into a range object, then look at the entire section where that range starts, then convert that section into a range, then tell me the position where that range starts. So all of that is just to work out a position which I then use to define the start of a range.

Code:
ActiveDocument.Range(Selection.Range.Sections(1).Range.Start, ActiveDocument.Range.End)
is saying
Go to the active document and then in that document think of a range that starts with the a position (as described in above paragraph) and ends at the end of the document.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote