![]() Lastly, to delete existing headers: Sub ClearExistingHeaders(oDoc As Word.Document)ĭim oSec As Word. RightIndent = Application.CentimetersToPoints(-1.6) LeftIndent = Application.CentimetersToPoints(-1.6) LineSpacing = Application.LinesToPoints(1) In earlier versions of Word, from the View menu, select Header and Footer. In Word 20, select the Insert tab, and then select either Header or Footer. Private Sub AddFooterToRange(rng As Word.Range) Click anywhere in the section of your document for which you want to create a different header or footer. The same principle applies for the Footer. Cell(1, 1). filename:="image path", LinkToFile:=False, SaveWithDocument:=True Columns(2).SetWidth ColumnWidth:=300, RulerStyle:=wdAdjustNone Rows.SetLeftIndent LeftIndent:=-37, RulerStyle:=wdAdjustNone Borders.OutsideLineStyle = wdLineStyleNone Borders.InsideLineStyle = wdLineStyleNone Tables.Add Range:=rng, NumRows:=1, NumColumns:=2, DefaultTableBehavior:=wdWord8TableBehavior, AutoFitBehavior:=wdAutoFitFixed ![]() Private Sub AddHeaderToRange(rng As Word.Range) Sub UpdateHeader()ĭim oDoc As Word.Document, oSec As Word.Section, rng As Word.Range An image on the left side and text on the right side. The example below creates a header in all pages, consisting of a table with two cells. You need to add the header/footer into the wdHeaderFooterFirstPage range for the first page and into wdHeaderFooterPrimary for all other pages depending on the header/footer settings of the document. = wdAlignParagraphRightĪ = wdSeekCurrentPageFooter , LinkToFile:=False, SaveWithDocument:=True FooterDistance = CentimetersToPoints(1.0) HeaderDistance = CentimetersToPoints(1.0) I have tried a few different methods such as iterating through each shape on the page but in that case, the header and footer prints out multiple times on each page depending on how many shapes are in the document.Ĭurrently my code is looking for any current header and footer and deleting them, then it just inserts my header and footer on the first page and leaves the remaining pages in the document's header and footer blank.Ĭan anyone tell me where I am going wrong? Sub HeaderFooter()Ī = wdSeekCurrentPageHeader ![]() I am trying to add a header and a footer to each page of a word document via a macro. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |