Just come across this oddity... (Word 2002, under Vista HP)

I don't seem to be able to change the values for TextRetrievalMode
(includehiddentext or includefields) when the range it is applied to is a
comment's range (mycomment.range)... Trying different view types on the
TextRetrievalMode object doesn't help either.

And for different comments the TextRetrievalMode settings seem different
(and inconsistent - so I can't compare comments for their "normal" text)

any ideas?

Re: Help with Range.TextRetrievalMode? by Tony

Tony
Sat Oct 13 12:54:58 PDT 2007

It works for me (2002, Vista Ultimate)

Set CommentRange = ActiveDocument.Comments(1).Range.Duplicate
Debug.Print CommentRange.Text
CommentRange.TextRetrievalMode.IncludeHiddenText = True
Debug.Print CommentRange.Text

produces

This comment hides text
This comment hides some hidden text

(a correct representation of my comment)

Can you post your code?

--
Enjoy,
Tony

"Julian" <Julian@discussions.microsoft.com> wrote in message
news:90178A0C-7121-46F9-B88E-4C024DA07388@microsoft.com...
> Just come across this oddity... (Word 2002, under Vista HP)
>
> I don't seem to be able to change the values for TextRetrievalMode
> (includehiddentext or includefields) when the range it is applied to is a
> comment's range (mycomment.range)... Trying different view types on the
> TextRetrievalMode object doesn't help either.
>
> And for different comments the TextRetrievalMode settings seem different
> (and inconsistent - so I can't compare comments for their "normal" text)
>
> any ideas?


Re: Help with Range.TextRetrievalMode? by Julian

Julian
Sun Oct 14 04:09:03 PDT 2007

I'll get back with some code later - after I have tested something based on
your example: I noticed immediately that you worked with a range duplicate
whereas I was working directly on the comment range. I don't immediately see
why that should make any difference but it's worth checking!

Thanks


Re: Help with Range.TextRetrievalMode? by Julian

Julian
Mon Oct 15 03:07:00 PDT 2007

OK - update.

Two discoveries:

1. You cannot set TextRetrievalMode with comment.range.TextRetrievalMode...
you have to assign the comment range to a range object and work with that

2. You cannot create e.g. an Index Field directly in a comment - but if you
copy and paste one into a comment, TextRetrievalMode.HiddenText = false gives
the plain text, and TextRetrievalMode.HiddenText = true includes the field
code text regardless of the IncludeFieldCode setting (i.e. Field Code is not
recognised as such and is treated purely as hidden text, which is how it is
formatted)

3. hidden text visibility (UI setting) determines the default state of
.IncludeHiddenText - i.e. if hidden text is visible and you *don't* want it,
you must explicitly turn it off...

That probably accounts for the problems I was having... some text was pasted
into a comment and brought a (hidden) Index Entry field code with it, and I
was working directly on the comment range and not indirectly via a range
object (doesn't need to be a duplicate)

Thanks for prodding me along...

Julian

PS Code that illustrates the above (for suitable comments!) as follows...

Sub testCommentHiddentText()
Dim aCom As Comment
Dim aStr As String
Dim aRange As Range

Set aCom = Selection.Comments(1)
aStr = aCom.Range.Text

Debug.Print "Working directly on comment range"
Debug.Print "Incl. Hidden Text = " & vbTab &
aCom.Range.TextRetrievalMode.IncludeHiddenText & vbTab & " Incl Field Codes =
" & vbTab & aCom.Range.TextRetrievalMode.IncludeFieldCodes & vbTab & " Result
= " & vbTab & aCom.Range.Text
aCom.Range.TextRetrievalMode.IncludeHiddenText = True
Debug.Print "Incl. Hidden Text = " & vbTab &
aCom.Range.TextRetrievalMode.IncludeHiddenText & vbTab & " Incl Field Codes =
" & vbTab & aCom.Range.TextRetrievalMode.IncludeFieldCodes & vbTab & " Result
= " & vbTab & aCom.Range.Text
aCom.Range.TextRetrievalMode.IncludeFieldCodes = True
Debug.Print "Incl. Hidden Text = " & vbTab &
aCom.Range.TextRetrievalMode.IncludeHiddenText & vbTab & " Incl Field Codes =
" & vbTab & aCom.Range.TextRetrievalMode.IncludeFieldCodes & vbTab & " Result
= " & vbTab & aCom.Range.Text

Debug.Print "Working on range object from Comment range"
Set aRange = aCom.Range
Debug.Print "Incl. Hidden Text = " & vbTab &
aRange.TextRetrievalMode.IncludeHiddenText & vbTab & " Incl Field Codes = " &
vbTab & aRange.TextRetrievalMode.IncludeFieldCodes & vbTab & " Result = " &
vbTab & aRange.Text
aRange.TextRetrievalMode.IncludeHiddenText = True
Debug.Print "Incl. Hidden Text = " & vbTab &
aRange.TextRetrievalMode.IncludeHiddenText & vbTab & " Incl Field Codes = " &
vbTab & aRange.TextRetrievalMode.IncludeFieldCodes & vbTab & " Result = " &
vbTab & aRange.Text
aRange.TextRetrievalMode.IncludeFieldCodes = True
Debug.Print "Incl. Hidden Text = " & vbTab &
aRange.TextRetrievalMode.IncludeHiddenText & vbTab & " Incl Field Codes = " &
vbTab & aRange.TextRetrievalMode.IncludeFieldCodes & vbTab & " Result = " &
vbTab & aRange.Text

Debug.Print "Working on duplicate range object from Comment range"
Set aRange = aCom.Range.Duplicate
Debug.Print "Incl. Hidden Text = " & vbTab &
aRange.TextRetrievalMode.IncludeHiddenText & vbTab & " Incl Field Codes = " &
vbTab & aRange.TextRetrievalMode.IncludeFieldCodes & vbTab & " Result = " &
vbTab & aRange.Text
aRange.TextRetrievalMode.IncludeHiddenText = True
Debug.Print "Incl. Hidden Text = " & vbTab &
aRange.TextRetrievalMode.IncludeHiddenText & vbTab & " Incl Field Codes = " &
vbTab & aRange.TextRetrievalMode.IncludeFieldCodes & vbTab & " Result = " &
vbTab & aRange.Text
aRange.TextRetrievalMode.IncludeFieldCodes = True
Debug.Print "Incl. Hidden Text = " & vbTab &
aRange.TextRetrievalMode.IncludeHiddenText & vbTab & " Incl Field Codes = " &
vbTab & aRange.TextRetrievalMode.IncludeFieldCodes & vbTab & " Result = " &
vbTab & aRange.Text

End Sub


Re: Help with Rang