Powershell - Add a new document to exisitng word file with page number of 2 -
I am trying to open an existing word file and am adding a new page for it. This new page will contain some content and I should always have this page position number 2. Therefore, the first page will always be the same and the second page should be added to the second page. So far I have this type of code:
$ day = get-date-format "dd-MMM-yyyy" $ has been filed - received-date-format "DD / MMM / - - HT "$ word = new object - com object word App $ word Visible = $ false $ doc = $ word.documents.open ( "$ home \ Desktop \ Network Report.docx") $ select = $ Sbdkselekshn $ Selection.InsertNewPage () #So, this page number 2 $ selection.Font .Size = 14 $ selection.Font.color = "wdColorBlack" $ Selection.TypeText ( "the network reported $ Filedate") should be included in the $ select .TypeParagraph () $ selectimage = $ selection.InlineShapes.AddPicture ( "$ Home \ desktop \ screenshot.jpeg") $ selection.TypeParagraph () $ stream = $ Doc.Sections.Item (1); $ Headers = $ section Header. ITEM (1); $ Footer = $ Section.Footers.Item (1); $ Header.Range.Text = "$ campus network report - $ day" $ doc.save ()
I made different attempts after going after various forms:
$ gotoPage1 = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage $ gotoNext1 = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToAbsolute $ gotoCount1 = null $ gotoName1 = 1 $ Selection.GoTo ([ref ] $ GotoPage1, [referee] $ goto next 1, [ref] $ goto clause 1, [ref] $ gaetonym 1)
But I had no luck, How to add a new page?
Here is an example, which should create a page number, and there the cursor is place. The number of pages in the document should not do any work.
Comments
Post a Comment