Hi

I've written the following simple bit of code (to reveal the first hidden
word in a cell) but as usual, it doesn't work as expected
______________________________________________________
GetOneWord()
'
' Macro enregistrée le 10/02/2006 par Dave Neve

Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend

With Selection.Font
.Hidden = False

End With
End Sub
_______________________________________________________

It reveals all the hidden words in the cell and not just the first one.

Why is this please?

Thanks

Dave Neve

Re: Revealing hidden words by Jezebel

Jezebel
Fri Feb 10 17:44:46 CST 2006

Because that extends the selection to include the first non-hidden word,
then reveals any hidden words that might have been in between.

As is so often the case, the problem comes from using the Selection object
when you should be using a Range.

Dim pRange as Word.Range
Dim pWord as Word.Range

set pRange = Selection.Cells(1).Range
For each pWord in pRange.Words
if pWord.Font.Hidden then
pWord.Font.Hidden = false
exit for
end if
Next


"Dave Neve" <NoAddressForSpammers@noway.fr> wrote in message
news:OaZP5soLGHA.3100@tk2msftngp13.phx.gbl...
> Hi
>
> I've written the following simple bit of code (to reveal the first hidden
> word in a cell) but as usual, it doesn't work as expected
> ______________________________________________________
> GetOneWord()
> '
> ' Macro enregistrée le 10/02/2006 par Dave Neve
>
> Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
>
> With Selection.Font
> .Hidden = False
>
> End With
> End Sub
> _______________________________________________________
>
> It reveals all the hidden words in the cell and not just the first one.
>
> Why is this please?
>
> Thanks
>
> Dave Neve
>



Re: Revealing hidden words by Helmut

Helmut
Fri Feb 10 17:43:22 CST 2006

Hi Dave,

not that simple.

> Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend

Selects the entire cell, if the next word
is the end-of-cell mark, and, here and now,
does more unexpected, not reproducable things.

It seems, if you want to access hidden text,
you have to show it first.

How about this one:

Sub test501()
Dim l As Long
Application.ScreenUpdating = False
ActiveWindow.View.ShowHiddenText = True
l = 1
With Selection.Cells(1).Range
While .Words(l).Font.Hidden = False
l = l + 1
Wend
.Words(l).Font.Hidden = False
End With
ActiveWindow.View.ShowHiddenText = False
Application.ScreenUpdating = True
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"




Re: Revealing hidden words by Helmut

Helmut
Fri Feb 10 18:05:37 CST 2006

Hi Jezebel,

excellent!

But completely illogical.

Do you have any explanation, for this:

Text in the cell:
Wort1 Wort2 Wort3 Wort4

Wort2 and Wort4 are hidden and not displayed.

Sub test00987354()
Dim pRange As Word.Range
Dim pWord As Word.Range
Set pRange = Selection.Cells(1).Range
For Each pWord In pRange.Words
MsgBox pWord ' = "Wort1" !!!
If pWord.Font.Hidden Then
pWord.Font.Hidden = False
' unhides Wort2 ???
Exit For
End If
Next
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"




Re: Revealing hidden words by Helmut

Helmut
Fri Feb 10 18:15:32 CST 2006

Don't bother,

I got it.

Helmut Weber

Re: Revealing hidden words by Tony

Tony
Sat Feb 11 09:06:44 CST 2006

To work properly this code must ensure it processes hidden text, whether
displayed or not ...

Dim pRange as Word.Range
Dim pWord as Word.Range

set pRange = Selection.Cells(1).Range
'===== Following line added =====
pRange.TextRetrievalMode.IncludeHiddenText = True
'=========================
For each pWord in pRange.Words
if pWord.Font.Hidden then
pWord.Font.Hidden = false
exit for
end if
Next

--
Enjoy,
Tony


"Jezebel" <warcrimes@whitehouse.gov> wrote in message
news:#0M05vpLGHA.3260@TK2MSFTNGP11.phx.gbl...
> Because that extends the selection to include the first non-hidden word,
> then reveals any hidden words that might have been in between.
>
> As is so often the case, the problem comes from using the Selection object
> when you should be using a Range.
>
> Dim pRange as Word.Range
> Dim pWord as Word.Range
>
> set pRange = Selection.Cells(1).Range
> For each pWord in pRange.Words
> if pWord.Font.Hidden then
> pWord.Font.Hidden = false
> exit for
> end if
> Next
>
>
> "Dave Neve" <NoAddressForSpammers@noway.fr> wrote in message
> news:OaZP5soLGHA.3100@tk2msftngp13.phx.gbl...
> > Hi
> >
> > I've written the following simple bit of code (to reveal the first
hidden
> > word in a cell) but as usual, it doesn't work as expected
> > ______________________________________________________
> > GetOneWord()
> > '
> > ' Macro enregistrée le 10/02/2006 par Dave Neve
> >
> > Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
> >
> > With Selection.Font
> > .Hidden = False
> >
> > End With
> > End Sub
> > _______________________________________________________
> >
> > It reveals all the hidden words in the cell and not just the first one.
> >
> > Why is this please?
> >
> > Thanks
> >
> > Dave Neve
> >
>
>



Re: Revealing hidden words by Helmut

Helmut
Sat Feb 11 09:14:38 CST 2006

Hi Tony,

excellent,

>pRange.TextRetrievalMode.IncludeHiddenText = True

there is always something to learn.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"