ลบและแทนที่หัวและท้ายของเอกสาร Microsoft Word

เปิด Microsoft WORD, ดู, มาโคร, ดูมาโคร, สร้างมาโครใหม่

ฟังก์ชัน a()

ประกาศตัวแปร myDialogs เป็น FileDialogs, oDoc เป็น Documents, oSecs เป็น Sections

ประกาศตัวแปร oFile เป็น Variant, myRange เป็น Range

เมื่อเกิดข้อผิดพลาด ดำเนินการต่อ

กำหนดกล่องโต้ตอบการเลือกโฟลเดอร์

กำหนด myDialogue=Application FileLog (msoFileDialogFilePicker)

ด้วย 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

กำหนด oDoc=Word Documents Open (FileName:=oFile, Visible:=False)

สำหรับ oSec ใน oDoc Sections วนซ้ำในเอกสารภายในส่วน

กำหนด 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

ด้วย myRange Font

สิ้นสุดด้วย

 

กำหนด 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

ถัดไป

ODoc Close True

ถัดไป

สิ้นสุดถ้า

สิ้นสุดด้วย

สิ้นสุดฟังก์ชัน

 

ปัญหาการเชื่อมต่อระหว่าง MACBOOK และ iPhone
- กระทู้ก่อนหน้า 02/23/2019 14:24
แก้ไขปัญหา: ไม่สามารถแก้ไขเอกสารคำที่แปลโดย DeepL ได้
กระทู้ถัดไป - 02/23/2019 14:24