|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
2楼的V,我贴出来。用起来应该没有问题。- Private Sub CommandButton1_Click()
- Dim MyDialog As FileDialog, GetStr(1 To 100) As String '100是我当时工作时的文档数
- On Error Resume Next
- Set MyDialog = Application.FileDialog(msoFileDialogFilePicker)
- With MyDialog
- .Filters.Clear
- .Filters.Add "所有WORD文件", "*.doc", 1
- .AllowMultiSelect = True
- i = 1
- If .Show = -1 Then
- For Each stiSelectedItem In .SelectedItems
- GetStr(i) = stiSelectedItem
- i = i + 1
- Next
- i = i - 1
- End If
-
- Application.ScreenUpdating = False
- For j = 1 To i Step 1
- Set Doc = Documents.Open(FileName:=GetStr(j), Visible:=True)
- Windows(GetStr(j)).Activate
- Selection.Find.ClearFormatting
- Selection.Find.Replacement.ClearFormatting
- With Selection.Find
- .Text = "^g"
- .Replacement.Text = ""
- .Forward = True
- .Wrap = wdFindContinue
- .Format = False
- .MatchCase = False
- .MatchWholeWord = False
- .MatchByte = True
- .MatchWildcards = False
- .MatchSoundsLike = False
- .MatchAllWordForms = False
- End With
- Selection.Find.Execute Replace:=wdReplaceAll
- Application.Run macroname:="Macro1"
- ActiveDocument.Save
- ActiveWindow.Close
- Next
- Application.ScreenUpdating = True
- End With
- MsgBox "批量删除图片完毕!请查看!!", vbInformation ‘建议这里的字可以改一下
- End Sub
复制代码 |
|