从以下代码TCN.docx
文件已成功使用
Application.ScreenUpdating = False
而不是
Visible:= False
Sub workonTCN()
Dim odoc As Document
Dim path As String
path = "C:\Users\Bilal\Desktop\TCN.docx"
Set odoc = Documents.Open(filename:=path)
Application.ScreenUpdating = False
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
With Selection.Find
.Text = "TI"
.Forward = True
.Wrap = wdFindStop
.Format = True
End With
Selection.Find.Execute
If Selection.Find.Found = True Then
Selection.MoveRight Unit:=wdCell
Selection.COPY
Else
End If
Windows("ROUGH").Activate
odoc.Close wdDoNotSaveChanges
Selection.PasteAndFormat (wdPasteDefault)
End sub
如何应用范围来查找没有Selection.Find
的文字?
答案 0 :(得分:2)
使用Range.Find而不是Selection.Find:
Dim rng As Word.Range
Set rng = odoc.Content
rng
Selection
(执行粘贴的最后一行除外)请注意,您可以删除用于激活要粘贴信息的窗口的行。