批量删除Word文档页眉或页脚的方法
,,,,,,,,,,word?ü?,?,,,??
1,,,,,,,,,2,,,
,,word,,,,,,,棬--,,--?,,,º,--
,,,,,,,Macro1,,,,?,,,,,,?,š,,,,Macro2,,,,?,,,,,,?,š,--,,,,,????
2,,,,,,,,--,,--,??,,
3,,,,,,--,,--,,
4,,,,,,,,?,š,,,,,,,???,
,,,,,,,,,,,,,,?,?,,
Sub,,,,?,,()??
Application.ScreenUpdating = False
Dim MyPath As String, i As Integer, myDoc As Document
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = ",,,,,,?,,,?,,," & ",,,,(,,,,,,,,,,,Word,?,,,?ü?,,)"???
If .Show = -1 Then
MyPath = .SelectedItems(1)
Else
Exit Sub
End If
End With
With Application.FileSearch
.LookIn = MyPath
.FileType = msoFileTypeWordDocuments
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Set myDoc = Documents.Open(FileName:=.FoundFiles(i))
' B,,,,,,滻?,
' ,,,,,,,,,,,,,?,,?,,,,,,,,?,,?
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
End If
End With
Application.ScreenUpdating = True
MsgBox ",,Word,?,,,?ü?,,,,,,,", 64, ",,,,,,,,,,,,,,"???
End Sub
,,,1-4,,,,,,,,,,?ü,,,,,,,,,,??
Sub ,,,,?ü()??
Dim myDialog As FileDialog, oDoc As Document, oSec As Section
Dim oFile As Variant, myRange As Range
On Error Resume Next
',,,,?,,,?,,,,,,,,,?
Set myDialog = Application.FileDialog(msoFileDialogFilePicker)
With myDialog
.Filters.Clear ',,,,,,,,?,,,,е,,,???
.Filters.Add ",,,, WORD ,?,", "*.doc", 1 ',,,,,,,,??,,,,WORD,?,??
.AllowMultiSelect = True ',,,,,,,,,?
If .Show = -1 Then ',,,
For Each oFile In .SelectedItems ',,,,,,,,,?,,,,??
Set oDoc = Word.Documents.Open(FileName:=oFile, Visible:=False)
For Each oSec In oDoc.Sections ',?,,?,,,,,?
Set myRange = oSec.Headers(wdHeaderFooterPrimary).Range
myRange.Delete ',,?ü,е,,,,,?
myRange.ParagraphFormat.Borders(wdBorderBottom).LineStyle =
wdLineStyleNone ',,,,,?,,,,
Set myRange = oSec.Footers(wdHeaderFooterPrimary).Range
myRange.Delete ',,?,,,е,,,,,?
Next
oDoc.Close True
Next
End If
End With
End Sub
5,,,,,,,,,??,
,,,,,,,,?ü?,,??
6,,,,,,--,,--,,
7,,,,,,,,,,,,,???
8,,,,,,,,,,,,,,,,?,,,,???