我試圖找到並與域代碼http://office.microsoft.com/en-us/word-help/field-codes-ref-field-HP005186139.aspx字VBA:查找和裁判的代碼替換
Sub replacereftag()
ReplacementText "<test>", "REF Test.Test1 "
End Sub
Private Sub ReplacementText(findtext As String, replacetext As String)
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = findtext
.myrange.Field = replacetext
.Wrap = wdFindContinue
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
問題是什麼? – Rick
我試圖替換字段代碼ref部分,但在這一點上我還沒有成功。它取代了文本,但不作爲參考文件。我只是想弄清楚參考代碼 – Jon
它仍然有點不清楚 - 你是否試圖用'Field object'替換文檔中的某些文本? –