In my ASPX page I want to find and replace some predefined words. I am
using the following code, but it say objWord.Selection is not there. (
where as this is supported by word )
Set objWord = document.OA1.ActiveDocument
Set objSelection = objWord.Selection
objSelection.Find.ClearFormatting
objSelection.Find.Replacement.ClearFormatting
objSelection.Find.Text = varFind
objSelection.Find.Replacement.Text = varReplace
objSelection.Find.Forward = True
objSelection.Find.Wrap = wdFindContinue
objSelection.Find.Format = False
objSelection.Find.MatchCase = False
objSelection.Find.MatchWholeWord = False
objSelection.Find.MatchWildcards = False
objSelection.Find.MatchSoundsLike = False
objSelection.Find.MatchAllWordForms = False
objSelection.Find.Execute
Please let me know how can I find and replace word in the client side
word with OA1 activeX.
One Response to “Replace words in Office ActiveX Control”
Leave a Reply
You must be logged in to post a comment.
February 19th, 2009 at 7:22 am
Try
Set objWord = document.OA1.ActiveDocument
objWord.Selectio.Find.ClearFormatting
objWord.Selectio.Find.Replacement.ClearFormatting
objWord.Selectio.Find.Text = varFind
objWord.Selectio.Find.Replacement.Text = varReplace
objWord.Selectio.Find.Forward = True
objWord.Selectio.Find.Wrap = wdFindContinue
objWord.Selectio.Find.Format = False
objWord.Selectio.Find.MatchCase = False
objWord.Selectio.Find.MatchWholeWord = False
objWord.Selectio.Find.MatchWildcards = False
objWord.Selectio.Find.MatchSoundsLike = False
objWord.Selectio.Find.MatchAllWordForms = False
objWord.Selectio.Find.Execute
Or use the follow method:
helpstring(”Replaces all the specified string value with another string value.”)
HRESULT WordReplace([in] BSTR Text, [in] BSTR ReplaceText, [in] VARIANT_BOOL MatchWholeWord, [in] VARIANT_BOOL MatchCase);
document.OA1.WordReplace “aaa”, “bbb”, true, true