|
楼主 |
发表于 2010-9-19 19:26
|
显示全部楼层
Sub 批量处理文档()
'
' 批量处理文档 Macro
' 宏在 2007-9-30 由 番茄花园 创建
'
Dim MyDialog As FileDialog, GetStr(1 To 40) As String ’40是我当时工作时的文档数
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
‘在此加入你要在每文档中要做的工作,可以是录制的宏
Application.Run macroname:="Macro1"
ActiveDocument.Save
ActiveWindow.Close
Next
Application.ScreenUpdating = True
End With
End Sub
有点像这个 但是不太理解 是EXCEL |
|