Arrebol - Chia sẻ kiến thức kết nối thành công

https://arrebol.edu.vn


Thủ tục loại bỏ toàn bộ Header và Footer trong Word

Header và Footer là những thành phần cố định của trang văn bản được trình bày trong phần mềm Microsoft Word. Bạn có thể sử dụng hoặc không sử dụng đều được.
VBA 250x250

VBA 250x250

Bước 1: Mở tệp Word mà bạn muốn xóa tất cả Header và Footer, nhấn giữ tổ hợp phím Alt và F11 để mở cửa sổ Microsoft Visual Basic for Applications. Nếu phím tắt của bạn không hoạt động, hãy kích chuột chọn tab Developer, chọn Visual Basic để mở cửa sổ Microsoft Visual Basic for Applications.

Bước 2: Nhấn chọn Insert, chọn Module và dán mã sau vào cửa sổ vừa xuất hiện.

Mã VBA: Xóa tất cả Header và Footer khác nhau trong cùng một tài liệu:
 

Sub RemoveHeadAndFoot()
'Update by Extendoffice
    Dim oSec As Section
    Dim oHead As HeaderFooter
    Dim oFoot As HeaderFooter
    For Each oSec In ActiveDocument.Sections
        For Each oHead In oSec.Headers
            If oHead.Exists Then oHead.Range.Delete
        Next oHead
        For Each oFoot In oSec.Footers
            If oFoot.Exists Then oFoot.Range.Delete
        Next oFoot
    Next oSec
     Selection.WholeStory
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.ParagraphFormat.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
Bước 3: Nhấn phím F5 hoặc nút Run (hình tam giác màu xanh lá cây trên thanh công cụ) để chạy mã VBA. Tới đây tất cả các Header và Footer đều đã bị xóa cùng một lúc.

Tác giả: Admin Arrebol

Bạn đã không sử dụng Site, Bấm vào đây để duy trì trạng thái đăng nhập. Thời gian chờ: 60 giây