sceneple.blogg.se

Word footer page x of y
Word footer page x of y





word footer page x of y

I hope this can make someone's life easier, and if anyone has a more elegant solution, I'd like to learn.Page numbers are printed in the header or footer and can be formatted as you would any text in the main document.

word footer page x of y

HeaderRange.Text = vbTab & DanObjL & ", " & DanObj & ". HeaderRange.Text = vbTab & " - O g l a s n i k j a v n e n a b a v k e - " I think it's because after adding the field range positioner doesn't stay behind but in front of the field. (headerRange, CurrentPage)Īfter adding the page number field, the following text would push the page number all the way to the right to the end. HeaderRange.Text = "Broj " & Br_Gl & " - Strana " HeaderRange.Text = "SLUŽBENI GLASNIK BiH" & vbCrLf Imports Word = ĭim headerRange As Word.Range = Section.Headers().Range The first line is the plain text "SLUŽBENI LIST BiH", and the second line should contain the issue number (text Broj), page number (Strana), - subtitle - date of issue Daywk var, day var, month var, year var. It't not the best and most "fancy" c#, but it works for me. That last line returns to the main document. SeekView = .WdSeekView.wdSeekMainDocument Add(s.Range, ref TotalPages, ref oMissing, ref oMissing) insert total pages field in the selection.

word footer page x of y

Object TotalPages = .WdFieldType.wdFieldNumPages create the field for total page number. Add(s.Range, ref CurrentPage, ref oMissing, ref oMissing) Object CurrentPage = .WdFieldType.wdFieldPage create the field for current page number S.ParagraphFormat.Alignment = .WdParagraphAlignment.wdAlignParagraphRight SeekView = .WdSeekView.wdSeekCurrentPageFooter move selection to page footer (Use wdSeekCurrentPageHeader for header) Document worddoc = (ref oMissing, ref oMissing, ref oMissing, ref oMissing) define worddoc as the word document object create missing object for compatibility with C#. Application wordapp = new .Application() instanciate wordapp as the Word application object Let me know if something about the question is not clear. Nothing that I tried quite worked for me entirely (I got somewhat close). Insert Where:=Selection.Range, RichText:=True I recorded this VBA macro, but it does not seem to be helpful. TypeText(" of ") įooterRange = į(footerRange, ) į = Ref fieldEmpty, ref autoText, ref preserveFormatting) įoreach (Word.Section section in ) Object autoText = "AUTOTEXT \"Page X of Y\" "







Word footer page x of y