J
JohnTheTemp
Strange happenings.
I have a macro that searches for highlighting and copies it to the
clipboard. Occasionally, the macro aborts with an error because there's
nothing to copy.
1) If I manually search for highlights, I don't find any.
2) The macro supposedly finds something, but the cursor is still sitting at
the top of the dcoument when the error occurs.
3) I tried to test for a zero-length field to work around the problem, but
the selected data wasn't zero-length. ???? Note #2.
4) I eventually traced the problem to certain cells in a table.
a) If I delete the data in that cell, the problem persists.
b) If I select the cells and "remove highlighting" then the macro works
fine.
I know the solution, but I need more..
* Does anyone know what might be happening?
* I want to find a way to train my macro to detect the problem and not
abort when it encounters it.
Just in case, here's the relevent portion of the macro (I've test it to see
if it is troubled by those nasty cells -- it is):
Sub temp3()
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
End With
If Selection.Find.Execute = True Then MsgBox "Found"
End Sub
I'm afraid I don't know how to let you examine the cells.
I have a macro that searches for highlighting and copies it to the
clipboard. Occasionally, the macro aborts with an error because there's
nothing to copy.
1) If I manually search for highlights, I don't find any.
2) The macro supposedly finds something, but the cursor is still sitting at
the top of the dcoument when the error occurs.
3) I tried to test for a zero-length field to work around the problem, but
the selected data wasn't zero-length. ???? Note #2.
4) I eventually traced the problem to certain cells in a table.
a) If I delete the data in that cell, the problem persists.
b) If I select the cells and "remove highlighting" then the macro works
fine.
I know the solution, but I need more..
* Does anyone know what might be happening?
* I want to find a way to train my macro to detect the problem and not
abort when it encounters it.
Just in case, here's the relevent portion of the macro (I've test it to see
if it is troubled by those nasty cells -- it is):
Sub temp3()
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
End With
If Selection.Find.Execute = True Then MsgBox "Found"
End Sub
I'm afraid I don't know how to let you examine the cells.