Board index » Visual Studio » Find problem
|
bweiler
|
Find problem
Visual Studio256
In the subroutine shown below, when it comes to .Replacement.ClearFormatting, my program aborts with the following error message: "Object is not connected to server." I don't know how to go about debugging this problem. Can someone please help me with some suggestions as to what might be wrong with my code? Thanks. Public Sub pbrpWordReplace(parReplaceType As pbreWordReplaceTypeEnum) Dim ReplaceStr As String ' pbrvLibWordDoc is a global, public variable With pbrvLibWordDoc.Content.Find .ClearFormatting .Replacement.ClearFormatting Select Case parReplaceType Case pbreWordReplaceBold .Font.Bold = True .Replacement.Font.Bold = False ReplaceStr = "<B>^&<b>" Case pbreWordReplaceItalic .Font.Italic = True .Replacement.Font.Italic = False ReplaceStr = "<I>^&<i>" Case pbreWordReplaceUnderline .Font.Underline = True .Replacement.Font.Underline = False ReplaceStr = "<U>^&<u>" Case Else ReplaceStr = "" End Select .Execute FindText:="", ReplaceWith:=ReplaceStr, Format:=True, Replace:=wdReplaceAll End With End Sub - |
