发布日期:2024-10-31 11:04 点击次数:65
Private Sub CommandButton1_Click()
'关闭屏幕刷新
Application.ScreenUpdating = False
'界说变量
Dim myFile$, myPath$, i%, myDoc As Object, myAPP As Object, txt$, Re_txt$
'成就期骗对象,建设临时进度
Set myAPP = New Word.Application
'知道采用文献夹对话框
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "采用目的文献夹"
If .Show = -1 Then
'读取采用的文献旅途
myPath = .SelectedItems(1)
Else
Exit Sub
End If
End With
'文献夹目次和文献完好旅途
myPath = myPath & ""
myFile = Dir(myPath & "\*.docx")
'取得被替换的笔墨
txt = InputBox("需要替换的笔墨:")
'取得替换文献
Re_txt = InputBox("替换成:")
'知道大开文档
myAPP.Visible = True '是否知道大开文档
'轮回处治文献夹中的沿路文献
Do While myFile <> "" '文献不为空
'大开文献
Set myDoc = myAPP.Documents.Open(myPath & "\" & myFile)
'判断文献是否受保护,仅对未受保护的文献灵验
If myDoc.ProtectionType = wdNoProtection Then
'查找替换
With myDoc.Content.Find
.Text = txt
.Replacement.Text = Re_txt
.Forward = True
.Wrap = 2
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=2
End With
End If
快播三级电影'成就文献窗口现象,幸免再次大开时被掩盖
Application.WindowState = wdWindowStateNormal
'保存并关闭文档
myDoc.Save
myDoc.Close
myFile = Dir
Loop
'关闭临时进度
myAPP.Quit
'大开屏幕更新
Application.ScreenUpdating = True
'输出教导信息
MsgBox ("沿路替换兑现!")
End Sub三上悠亚 肛交
本站仅提供存储做事,系数本体均由用户发布,如发现存害或侵权本体,请点击举报。