![]() For instance, don't use Selection without qualifying it. Otherwise you run the risk of creating an extra Word.Application object that isn't controlled by you. If you want to run the code from another application without setting a reference to the Word object library, you must replace all Word-specific constants with their values, and take great care to make all objects refer back directly or indirectly to the Set doc = Documents.Open("c:\report.txt") ![]() If you want to run this code from within Word, there is no need to create a Word.Application object: Sub InsertPageBreaks() Your code is a mixture between early binding (it refers to Word-specific constants such as wdParagraph) and late binding (word and doc are declared as objects). ![]() Selection.Collapse Direction:=wdCollapseEnd Selection.MoveDown unit:=wdParagraph, Count:=1 PageSetup.RightMargin = InchesToPoints("0.5") PageSetup.LeftMargin = InchesToPoints("0.5") PageSetup.Orientation = wdOrientLandscape Set word = CreateObject("word.application") When editing your Header or Footer, you can. Odd Page Insert a section break and start a new section on an odd-numbered page. Even Page Insert a section break and start a new section on an even-numbered page. But I don't know why page break only inserted before instead of the whole document. This is typically used when jumping from a single column page to a 2-3 column page. I'm trying to insert page break in a Word document with using VBA.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |