S
scorpion53061
Hi all MS Word app need to work with 2000 and up. This is vb.net code
adapted from vba. I am hoping that you folks have suggestions.
I am in a situation where I need to find a block of text and delete it from
the document - but only find the next instance of that text and stop there.
The code below worked fine except
1. my boss wants to be able to do a text deletion that was larger than was
allowed. How can I meet his requst?
2. and it went through to the bottom of the document deleting all entries
instead of stopping at the first one. When I switched to wdFindStop it gave
me out of range errors.
I suspect I am overlooking obvious solutions.
thank you for any help you give.....
selectedtext is a string variable.
selectedtext = Dstemplate1.Tables(0).Rows(0).Item("templateContent")
oDoc.Content.Application.Selection.Bookmarks.Add("startingpoint",
oDoc.Content.Application.Selection)
While
oDoc.Content.Application.Selection.Find.Execute(FindText:=selectedtext, _
Wrap:=oDoc.Content.Find.Wrap = 1) 'Word.WdFindWrap.wdFindContinue)
oDoc.Content.Application.Selection.Find.Execute(FindText:=selectedtext, _
ReplaceWith:=" ", _
Replace:=oDoc.Content.Application.Selection.Find.Replacement.Text = " ", _
Wrap:=oDoc.Content.Application.Selection.Find.Wrap = 1)
'WdFindWrap.wdFindContinue)
oDoc.Content.Application.Selection.Delete()
End While
oDoc.Content.Application.ActiveDocument.Bookmarks.Item("startingpoint").Sele
ct()
oDoc.Content.Application.ActiveDocument.Bookmarks.Item("startingpoint").Dele
te()
adapted from vba. I am hoping that you folks have suggestions.
I am in a situation where I need to find a block of text and delete it from
the document - but only find the next instance of that text and stop there.
The code below worked fine except
1. my boss wants to be able to do a text deletion that was larger than was
allowed. How can I meet his requst?
2. and it went through to the bottom of the document deleting all entries
instead of stopping at the first one. When I switched to wdFindStop it gave
me out of range errors.
I suspect I am overlooking obvious solutions.
thank you for any help you give.....
selectedtext is a string variable.
selectedtext = Dstemplate1.Tables(0).Rows(0).Item("templateContent")
oDoc.Content.Application.Selection.Bookmarks.Add("startingpoint",
oDoc.Content.Application.Selection)
While
oDoc.Content.Application.Selection.Find.Execute(FindText:=selectedtext, _
Wrap:=oDoc.Content.Find.Wrap = 1) 'Word.WdFindWrap.wdFindContinue)
oDoc.Content.Application.Selection.Find.Execute(FindText:=selectedtext, _
ReplaceWith:=" ", _
Replace:=oDoc.Content.Application.Selection.Find.Replacement.Text = " ", _
Wrap:=oDoc.Content.Application.Selection.Find.Wrap = 1)
'WdFindWrap.wdFindContinue)
oDoc.Content.Application.Selection.Delete()
End While
oDoc.Content.Application.ActiveDocument.Bookmarks.Item("startingpoint").Sele
ct()
oDoc.Content.Application.ActiveDocument.Bookmarks.Item("startingpoint").Dele
te()