Barbara,
You can use "Selection.Paragraphs.First" or "Selection.Paragraphs(1)" to
refer to the first paragraph in the selection (this works even if the
"selection" is just the cursor sitting in the paragraph). You can do
something similar for other objects--(mySentence.Paragraphs(1) or
Selection.Sentences(1).
I'd also recommend using the Range object whenever possible. I'm no expert,
but as I've learned more about VBA, I've found the Range object to be
incredibly useful in many of the places where I first thought I had to use
the Selection object. (Obviously here, you're starting with the Selection
object, but in other cases, it can help.) You don't have to worry about
what's selected if you use a Range, and you can use Selection and Range
together to do interesting things.
Hope this helps,
Ben
"Barbara" wrote:
> I am working on a macro to format graphics. (I owe it mainly to one of the
> Word MVPs, but I have forgotten exactly where I found it. I am grateful to
> the author, whoever it was.)
>
> The macro starts by checking whether a floating shape, in-line shape, or
> neither is selected. The in-line case is the one where I need some help. I
> want to convert it to a floating shape and specify some layout settings. That
> part is working fine. I also want to check whether the shape is in an
> otherwise empty paragraph and, if so, delete the paragraph, leaving the shape
> anchored to the preceding paragraph.
>
> My current strategy is:
>
> If an in-line shape is selected, then,
> If the paragraph where the selection starts contains two characters
> (namely, the shape and the paragraph break),
> move the shape up one paragraph,
> delete the now-empty paragraph
> end if
> convert to a floating shape
> end if
> etc.
>
> After looking around on this site and the Word MVP site, I have constructed
> an expression that works (I think) for "the paragraph where the selection
> starts." But it is astonishingly long and obscure.
>
> What is the simplest way of writing this expression? It seems like this is a
> rather basic concept (also applicable to "the paragraph that holds this
> sentence," "the table that holds this cell," "the section that holds this
> character,"...) But I'm not finding any info about how to refer to it.
>
> Thanks for all your help!
> --
> Barbara Hill