2/15/2023 0 Comments Insert file name in word footer![]() Personally, however, rather than build the document from scratch every time I call the macro, I would create a template, open the document in ReadOnly mode, and use find and replace to replace any dynamic data. Footers(wdHeaderFooterPrimary).Range.Text = ThisWorkbook.FullName If you need to have the Excel workbook's filepath / name in the file, then you only need to refer to the ThisWorkbook object and its FullName property. Footers(wdHeaderFooterPrimary).Range.Text = FileName Footers(wdHeaderFooterPrimary).PageNumbers.Add PageNumberAlignment:=wdAlignPageNumberLeft, FirstPage:=True Headers(wdHeaderFooterPrimary). SrcePath ![]() 'Build your file path and file name here I am using ThisWorkbook assuming we are exporting to the same directory as the workbook, and calling the exported document "mydocument.docx"įileName = ThisWorkbook.Path
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |