如何給資料夾中的word文件批次修改頁首頁尾和水印 Private Sub CommandButton1_Click() Dim doc As Document, ph$, f$ ph = ThisDocument.Path & "\新建資料夾\" f = Dir(ph & "*.doc*") Do While f <> "" Set doc = Documents.Open(ph & f, Visible:=False) doc.Sections(1).Headers(1).Range.Text = "課本知識要點彙總" With doc.Sections(1).Headers(1).Shapes.AddPicture(ph & "水印圖片.png", 0, 1) .Height = CentimetersToPoints(21) .Width = CentimetersToPoints(51) .RelativeHorizontalPosition = 0: .Left = wdShapeCenter .RelativeVerticalPosition = 0: .Top = wdShapeCenter End With doc.Close -1, 1 f = Dir Loop MsgBox "操作完畢並儲存!" End Sub
如何給資料夾中的word文件批次修改頁首頁尾和水印 Private Sub CommandButton1_Click() Dim doc As Document, ph$, f$ ph = ThisDocument.Path & "\新建資料夾\" f = Dir(ph & "*.doc*") Do While f <> "" Set doc = Documents.Open(ph & f, Visible:=False) doc.Sections(1).Headers(1).Range.Text = "課本知識要點彙總" With doc.Sections(1).Headers(1).Shapes.AddPicture(ph & "水印圖片.png", 0, 1) .Height = CentimetersToPoints(21) .Width = CentimetersToPoints(51) .RelativeHorizontalPosition = 0: .Left = wdShapeCenter .RelativeVerticalPosition = 0: .Top = wdShapeCenter End With doc.Close -1, 1 f = Dir Loop MsgBox "操作完畢並儲存!" End Sub