Xóa và thay thế hàng loạt phần đầu trang và chân trang của tài liệu Microsoft Word

Mở microsoft WORD, xem, macro, xem macro, tạo một macro mới

Sub a()

Dim myDialogs As FileDialogs, oDoc As Documents, oSecs As Sections

Dim oFile As Variant, myRange As Range

On Error Resume Next

Định nghĩa hộp thoại chọn thư mục

Set myDialogue=Application FileLog (msoFileDialogFilePicker)

With myDialogs

. Filters. Clear ‘Clears all items in the file filters

. Filters. Add “All Word Files”, “*. doc, *. docx”, 1 ‘Add filters to all Word files

. AllowMultiSelect=True ‘Allow multiple selections

If Show=-1 Then ‘OK

For Each oFile In SelectedItems’ loop through all selected items

Set oDoc=Word Documents Open (FileName:=oFile, Visible:=False)

For Each oSec In oDoc Sections document loop within sections

Set myRange=oSec Headers (wdHeaderFooterPrimary) Range

MyRange Delete ‘Delete the content in the header

MyRange Text=”www.jincan. net”

MyRange ParagraphFormat Alignment=wdAlignParagraphCenter ‘Center text

MyRange ParagraphFormat Borders (wdBorderBottom) LineStyle=wdLineStyleNone ‘Paragraph bottom border line

With myRange Font

End With

 

Set myRange=oSec Footers (wdHeaderFooterPrimary) Range

MyRange Delete ‘Delete the content in the footer

MyRange Collapse wdCollapseEnd

MyRange InsertAfter Page Number

MyRange Fields Add Range:=myRange, Type:=wdFieldEmpty, Text:=”PAGE”, PreserveFormatting:=True

MyRange ParagraphFormat Alignment=wdAlignParagraphCenter ‘Center page numbers

Next

ODoc Close True

Next

End If

End With

End Sub

 

Vấn đề kết nối MACBOOK và iPhone
« Bài viết trước 02/23/2019 14:24
Đã giải quyết: Không thể chỉnh sửa tài liệu Word đã dịch của DeepL
Bài viết tiếp theo » 02/23/2019 14:24