Dim Fdlg As FileDialog, Fl
Dim Fso, Fld, Fln, Wk
Set Fdlg = Application.FileDialog(msoFileDialogFolderPicker)
With Fdlg
If .Show = -1 Then
MyPath = .SelectedItems(1)
Else
Exit Sub
End If
End With
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Fld = Fso.GetFolder(MyPath)
Set Fln = Fld.Files
For Each Wk In Fln
Set myDoc = Documents.Open(FileName:=Fld & "\" & Wk.Name)
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
With Selection.ParagraphFormat
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
With .Borders
.DistanceFromTop = 1
.DistanceFromLeft = 4
.DistanceFromBottom = 1
.DistanceFromRight = 4
.Shadow = False
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth075pt
.DefaultBorderColor = wdColorAutomatic
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.Sections(1).Footers(1).PageNumbers.Add PageNumberAlignment:= _
wdAlignPageNumberRight, FirstPage:=True
" 以上可以換成是你自己錄製的宏
" C公共部分的程式碼
Application.DisplayAlerts = False "強制執行“是”
"ActiveDocument.Saved = True"強制執行“否”
ActiveDocument.Close "退出
Next
Dim Fdlg As FileDialog, Fl
Dim Fso, Fld, Fln, Wk
Set Fdlg = Application.FileDialog(msoFileDialogFolderPicker)
With Fdlg
If .Show = -1 Then
MyPath = .SelectedItems(1)
Else
Exit Sub
End If
End With
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Fld = Fso.GetFolder(MyPath)
Set Fln = Fld.Files
For Each Wk In Fln
Set myDoc = Documents.Open(FileName:=Fld & "\" & Wk.Name)
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.WholeStory
With Selection.ParagraphFormat
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
With .Borders
.DistanceFromTop = 1
.DistanceFromLeft = 4
.DistanceFromBottom = 1
.DistanceFromRight = 4
.Shadow = False
End With
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth075pt
.DefaultBorderColor = wdColorAutomatic
End With
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End If
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.Sections(1).Footers(1).PageNumbers.Add PageNumberAlignment:= _
wdAlignPageNumberRight, FirstPage:=True
" 以上可以換成是你自己錄製的宏
" C公共部分的程式碼
Application.DisplayAlerts = False "強制執行“是”
"ActiveDocument.Saved = True"強制執行“否”
ActiveDocument.Close "退出
Next