J
Jonathan Sachs
I've written a macro which visits each paragraph in a table cell and
hides it or unhides it depending on its style. The macro works
correctly, but is very slow. Each iteration of the per-paragraph loop
appears to take a large fraction of the second, and the fractions add
up.
I'm trying to be rewrite the macro to eliminate the per-paragraph
loop. One step in the rewritten macro is to hide or unhide the entire
text of the cell. It isn't working. I can set the text's Font.Hidden
property, but it has no effect. That is, VBA neither changes the
text's Hidden property nor changes the contents of the window. (Nor
does it gives me an error.)
Here's an extract of the code:
Dim msgRange As Range
' . . .
Set msgRange = Selection.Cells(1).Range ' Select the cell.
msgRange.MoveLeft unit:=wdcharacter,count:=1,extend:=wdextend '
Just the text in the cell.
msgRange.Font.Hidden = True ' Hide
everything.
I tried hiding the text by hand (which works) and recording the
operation in a macro. The macro does exactly the same thing I do,
except that it operates on Selection instead of a Range variable. I
tried hiding Selection.Range in the immediate window (executing the
exact statement from the recorded macro) and THAT has no effect.
Does anybody know what Word is doing to me, and how to work around it?
My mail address is jsachs177 at earthlink dot net.
hides it or unhides it depending on its style. The macro works
correctly, but is very slow. Each iteration of the per-paragraph loop
appears to take a large fraction of the second, and the fractions add
up.
I'm trying to be rewrite the macro to eliminate the per-paragraph
loop. One step in the rewritten macro is to hide or unhide the entire
text of the cell. It isn't working. I can set the text's Font.Hidden
property, but it has no effect. That is, VBA neither changes the
text's Hidden property nor changes the contents of the window. (Nor
does it gives me an error.)
Here's an extract of the code:
Dim msgRange As Range
' . . .
Set msgRange = Selection.Cells(1).Range ' Select the cell.
msgRange.MoveLeft unit:=wdcharacter,count:=1,extend:=wdextend '
Just the text in the cell.
msgRange.Font.Hidden = True ' Hide
everything.
I tried hiding the text by hand (which works) and recording the
operation in a macro. The macro does exactly the same thing I do,
except that it operates on Selection instead of a Range variable. I
tried hiding Selection.Range in the immediate window (executing the
exact statement from the recorded macro) and THAT has no effect.
Does anybody know what Word is doing to me, and how to work around it?
My mail address is jsachs177 at earthlink dot net.