Re: Range Oddity by Tony
Tony
Wed Dec 06 14:26:50 CST 2006
The Range is not collapsed. The added Field (or FormField) should replace
the Range but cannot (or will not) do so when the range includes the end of
cell mark. FormFields.Add decides to add before the Range and Fields.Add
just goes belly up. Who knows why they are different? Sometimes I wonder
too!
--
Enjoy,
Tony
"Greg Maxey" <gmaxey@mvps.org> wrote in message
news:1165354133.764937.40140@16g2000cwy.googlegroups.com...
> Helmut,
>
> Consider what happens when you run this:
> Sub RangeTest()
> Dim oRng1 As Word.Range
> Dim oRng2 As Word.Range
> Dim i As Long
> For i = 1 To 2
> Set oRng1 = ActiveDocument.Tables(1).Rows(1).Cells(2).Range
> Set oRng2 = ActiveDocument.Tables(1).Rows(1).Cells(5).Range
> ActiveDocument.FormFields.Add oRng1, wdFieldFormTextInput
> oRng2.End = oRng2.End - 1 ' <<< no way without it
> ActiveDocument.Fields.Add oRng2, wdFieldQuote, "Test"
> Next i
> End Sub
>
> You get two formfields. Text2 preceeds Text1 in the cell. Apparantly
> the FormField (property I guess) causes the range to automatically
> collapse to the start of the cell.
>
>
>
>
>
>
>
> Helmut Weber wrote:
>> Hi Greg,
>>
>> its endless.
>>
>> It seems, that for the first range it works.
>> Not so for the second, unless you reduce the range.
>>
>> Sub RangeTest()
>> Dim oRng1 As Word.Range
>> Dim oRng2 As Word.Range
>> Set oRng1 = ActiveDocument.Tables(1).Rows(1).Cells(2).Range
>> Set oRng2 = ActiveDocument.Tables(1).Rows(1).Cells(5).Range
>> ActiveDocument.FormFields.Add oRng1, wdFieldFormTextInput
>> oRng2.End = oRng2.End - 1 ' <<< no way without it
>> ActiveDocument.Fields.Add oRng2, wdFieldQuote, "Test"
>> End Sub
>>
>>
>> >I wonder why
>>
>> I wonder, too.
>>
>> MSFT should, might, hire all MVPs, and Jezebel, too ...
>>
>> --
>> Greetings from Bavaria, Germany
>>
>> Helmut Weber, MVP WordVBA
>>
>> Win XP, Office 2003
>> "red.sys" & Chr$(64) & "t-online.de"
>