You can simplify your code (and make changes to the document by running the userform again) if you adopt the following function.
As for the page numbering, you need to insert a page field in the footer and then update the start number for the current section from your text box as included below, then update the field in the footer.
Option Explicit Private Sub NęsteButton1_Click() Dim oFooter As HeaderFooter Dim iPage As Integer FillBM "selskabsnavn1", TextBox1.Value FillBM "selskabsnavn2", TextBox1.Value FillBM "selskabsnavn3", TextBox1.Value FillBM "adresse", TextBox2.Value FillBM "postnr", TextBox3.Value FillBM "by", TextBox4.Value FillBM "cvr", TextBox5.Value FillBM "senesteaccept", TextBox6.Value FillBM "dato", TextBox7.Value FillBM "bestyrelse1", TextBox8.Value FillBM "bestyrelse2", TextBox9.Value FillBM "bestyrelse3", TextBox10.Value iPage = TextBox11.Value Set oFooter = Selection.Sections(1).Footers(wdHeaderFooterPrimary) With oFooter.PageNumbers .NumberStyle = wdPageNumberStyleArabic .RestartNumberingAtSection = True .StartingNumber = iPage End With oFooter.Range.Fields.Update Hide End Sub Private Sub FillBM(strbmName As String, strValue As String) 'Graham Mayor - http://www.gmayor.com Dim orng As Range With ActiveDocument On Error GoTo lbl_Exit Set orng = .Bookmarks(strbmName).Range orng.Text = strValue orng.Bookmarks.Add strbmName End With lbl_Exit: Set orng = Nothing Exit Sub End Sub




Reply With Quote