怎样批量替换多个word文档中的文字比如将十个doc文件中的abc换成xyz 在线待解分数立结
怎样批量替换多个word文档中的文字比如将十个doc文件中的abc换成xyz在线待解分数立结...
怎样批量替换多个word文档中的文字比如将十个doc文件中的abc换成xyz 在线待解分数立结
展开
5个回答
展开全部
利用VBA就可以了,新建一空白WORD文档,放置一个按钮,写入如下代码:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim myPas As String, myPath As String, i As Integer, myDoc As Document
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "选择目标文件夹"
If .Show = -1 Then
myPath = .SelectedItems(1)
Else
Exit Sub
End If
End With
myPas = InputBox("请输入打开密码:")
With Application.FileSearch
.LookIn = myPath
.FileType = msoFileTypeWordDocuments
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Set myDoc = Documents.Open(FileName:=.FoundFiles(i), Passworddocument:=myPas)
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "abc"
.Replacement.Text = "xyz"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
myDoc.Save
myDoc.Close
Set myDoc = Nothing
Next
End If
End With
Application.ScreenUpdating = True
End Sub
然后点击下按钮,选择要放置多个WORD文档所在的文件夹,确定后即可完成!注意如果WORD文档没有加密的话,密码项就不填,直接确认。
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim myPas As String, myPath As String, i As Integer, myDoc As Document
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "选择目标文件夹"
If .Show = -1 Then
myPath = .SelectedItems(1)
Else
Exit Sub
End If
End With
myPas = InputBox("请输入打开密码:")
With Application.FileSearch
.LookIn = myPath
.FileType = msoFileTypeWordDocuments
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Set myDoc = Documents.Open(FileName:=.FoundFiles(i), Passworddocument:=myPas)
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "abc"
.Replacement.Text = "xyz"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
myDoc.Save
myDoc.Close
Set myDoc = Nothing
Next
End If
End With
Application.ScreenUpdating = True
End Sub
然后点击下按钮,选择要放置多个WORD文档所在的文件夹,确定后即可完成!注意如果WORD文档没有加密的话,密码项就不填,直接确认。
参考资料: http://hi.baidu.com/mizuda/blog/item/61bce7f41d8f1928bd310972.html
博思aippt
2024-07-20 广告
2024-07-20 广告
作为深圳市博思云创科技有限公司的工作人员,对于Word文档生成PPT的操作,我们有以下建议:1. 使用另存为功能:在Word中编辑完文档后,点击文件->另存为,选择PowerPoint演示文稿(*.pptx)格式,即可将文档内容转换为PPT...
点击进入详情页
本回答由博思aippt提供
展开全部
这是我的思路,仅供参考:
Sub 替换()
Dim Dia As FileDialog, Fil As Variant, Doc As Document
Set Dia = Application.FileDialog(msoFileDialogFilePicker)
With Dia
.Filters.Clear
.Filters.Add "所有 WORD 文件", "*.doc", 1
.AllowMultiSelect = True
If .Show <> -1 Then Exit Sub
For Each Fil In .SelectedItems
Set Doc = Documents.Open(FileName:=Fil, Visible:=False)
With Doc
Doc.Content.Find.Execute findtext:="abc", replacewith:="xyz", _
MatchWildcards:=False, Replace:=wdReplaceAll
.Close True
End With
Next Fil
End With
End Sub
Sub 替换()
Dim Dia As FileDialog, Fil As Variant, Doc As Document
Set Dia = Application.FileDialog(msoFileDialogFilePicker)
With Dia
.Filters.Clear
.Filters.Add "所有 WORD 文件", "*.doc", 1
.AllowMultiSelect = True
If .Show <> -1 Then Exit Sub
For Each Fil In .SelectedItems
Set Doc = Documents.Open(FileName:=Fil, Visible:=False)
With Doc
Doc.Content.Find.Execute findtext:="abc", replacewith:="xyz", _
MatchWildcards:=False, Replace:=wdReplaceAll
.Close True
End With
Next Fil
End With
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ctrl+h 查找内容 替换内容 写好 然后选全部替换
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
全能字符串替换机7.0无限制版,支持office2003
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
先选定,在换输入法就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |