TT
Mon May 02 12:04:06 CDT 2005
This approach should work well. The general nature of what I am doing is
cleaning up documents that are compiled from several independent files. In
some cases, one or more of the component files consist entirely of a single
text box. A typical compiled file might have the structure below:
Component 1:
normal paragraphs
Component 2:
1 big text box
Component 3:
normal paragraphs
"Helmut Weber" <elmkqznfwvccbf@mailinator.com> wrote in message
news:8pic7197qe5moijfe1vehoav19irqapa6r@4ax.com...
> Hi Tom,
>
>>I have dug around the help files but have been unable to find any
>>documentation on how to determine whether a paragraph or range contains a
>>text box.
>
> They don't "contain" it at all. But the shape has an anchor property,
> which tells you by way of the character, to which they are connected,
> to which paragraph they belong.
>
> So here we go:
>
> Sub test570()
> Dim oShp As Shape ' a shape
> Dim lPrg As Long ' the position of the anchor
> Dim rTmp As Range ' a temporary range
> Dim nPrg As Long ' number of paragraph anchor is in
> Dim lShp As Long ' counter for shapes
> With ActiveDocument.Shapes
> For lShp = .Count To 1 Step -1
> If .Item(lShp).Type = msoTextBox Then
> sTxt = .Item(lShp).TextFrame.TextRange.Text
> lPrg = .Item(lShp).Anchor.Start
> Set rTmp = ActiveDocument.Range(Start:=0, End:=lPrg)
> nPrg = rTmp.Paragraphs.Count + 1
> ActiveDocument.Paragraphs(nPrg).Range.Text = _
> ActiveDocument.Paragraphs(nPrg).Range.Text & " " & sTxt
> End If
> Next
> End With
> End Sub
>
> My example checks whether a frame is of the right type,
> checks the number of the character in the doc it is connected
> to (anchor), counts the number od paragraphs from doc's start to
> the anchor, adds 1, as here it is about whole paragraphs,
> reads the text from the shape and adds it to the text of
> the paragraph in question, whereby the shape disappers
> without any further action.
>
> And all that doesn't mean that there would be anything
> wrong with Greg's approach, as far as I see.
>
> Have a nice day.
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP
> "red.sys" & chr(64) & "t-online.de"
> Word XP, Win 98
>
http://word.mvps.org/
>
>
>
>
>
>
>
>