它找不到&替换单词我想要能找到单词&的初始字符的代码。用其他字符串替换完整的单词
这是我用来查找&的代码替换文档中的单词
Imports Word = Microsoft.Office.Interop.Word
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objWordApp As Word.Application
objWordApp = New Word.Application
Dim TLA_name = "TL"
Dim objDoc As Word.Document
Dim rng As Word.Range
'Show the Word application window if checked.
objWordApp.Visible = True
'Open an existing document.
objWordApp.Documents.Open("C:\Temp\SLLD-SW-230-MNS.docx")
objDoc = objWordApp.ActiveDocument
rng = objDoc.Content
rng.Find.Text = "TLA"
rng.Find.Replacement.Text = TLA_name
rng.Find.Execute(ReplaceWith:=Word.WdReplace.wdReplaceAll)
'Find and replace some text.
objDoc.Content.Find.Execute(FindText:="DDD_MNS_", _
ReplaceWith:=TLA_name, _
Replace:=Word.WdReplace.wdReplaceOne)
While objDoc.Content.Find.Execute(FindText:=" ", _
Wrap:=Word.WdFindWrap.wdFindContinue)
objDoc.Content.Find.Execute(FindText:=" ", ReplaceWith:=" ", _
Replace:=Word.WdReplace.wdReplaceAll, _
Wrap:=Word.WdFindWrap.wdFindContinue)
End While
'Save and close the document.
objWordApp.Documents.Item(1).Save()
Console.WriteLine("Replaced all instances of 'VB' with 'Visual Basic Express' " & _
"and saved the document")
objWordApp.Documents.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
objWordApp.Quit()
objWordApp = Nothing
End Sub
End Class