Kristoffer
12-18-2017, 03:51 AM
I am working on a number of documents, where the user enters some data in a userform, which is entered into the document via bookmarks.
Now I need to make a document, where the pagenumber begins with the number entered in the userform.
The master document has a footer with a page number and another bookmark with the clients name, so all I need is to feed the existing pagenumber with the start value.
My userform looks like this:
21201
The start value for the pagenumber is "Start med side" in TextBox 11.
My code for the macro looks like below. I have no problem entering a value in TextBox11 and placing the value in a bookmark where the pagenumber is located, but if the value is 56, then all pages are numbered 56.
Private Sub NęsteButton1_Click()
Dim Kundenavn As Range
Set Kundenavn = ActiveDocument.Bookmarks("selskabsnavn1").Range
Kundenavn.Text = Me.TextBox1.Value
Set Kundenavn = ActiveDocument.Bookmarks("selskabsnavn2").Range
Kundenavn.Text = Me.TextBox1.Value
Set Kundenavn = ActiveDocument.Bookmarks("selskabsnavn3").Range
Kundenavn.Text = Me.TextBox1.Value
Dim Adresse As Range
Set Adresse = ActiveDocument.Bookmarks("adresse").Range
Adresse.Text = Me.TextBox2.Value
Set Postnr = ActiveDocument.Bookmarks("postnr").Range
Postnr.Text = Me.TextBox3.Value
Dim by As Range
Set by = ActiveDocument.Bookmarks("by").Range
by.Text = Me.TextBox4.Value
Dim CVRnummer As Range
Set CVRnummer = ActiveDocument.Bookmarks("cvr").Range
CVRnummer.Text = Me.TextBox5.Value
Dim senesteaccept As Range
Set senesteaccept = ActiveDocument.Bookmarks("senesteaccept").Range
senesteaccept.Text = Me.TextBox6.Value
Dim underskriftdato As Range
Set underskriftdato = ActiveDocument.Bookmarks("dato").Range
underskriftdato.Text = Me.TextBox7.Value
Dim bestyrelsesmedlem1 As Range
Set bestyrelsesmedlem1 = ActiveDocument.Bookmarks("bestyrelse1").Range
bestyrelsesmedlem1.Text = Me.TextBox8.Value
Dim bestyrelsesmedlem2 As Range
Set bestyrelsesmedlem2 = ActiveDocument.Bookmarks("bestyrelse2").Range
bestyrelsesmedlem2.Text = Me.TextBox9.Value
Dim bestyrelsesmedlem3 As Range
Set bestyrelsesmedlem3 = ActiveDocument.Bookmarks("bestyrelse3").Range
bestyrelsesmedlem3.Text = Me.TextBox10.Value
Need code here
Me.Repaint
UserForm1.Hide
End Sub
Thanks for any assistance.
Kristoffer
Now I need to make a document, where the pagenumber begins with the number entered in the userform.
The master document has a footer with a page number and another bookmark with the clients name, so all I need is to feed the existing pagenumber with the start value.
My userform looks like this:
21201
The start value for the pagenumber is "Start med side" in TextBox 11.
My code for the macro looks like below. I have no problem entering a value in TextBox11 and placing the value in a bookmark where the pagenumber is located, but if the value is 56, then all pages are numbered 56.
Private Sub NęsteButton1_Click()
Dim Kundenavn As Range
Set Kundenavn = ActiveDocument.Bookmarks("selskabsnavn1").Range
Kundenavn.Text = Me.TextBox1.Value
Set Kundenavn = ActiveDocument.Bookmarks("selskabsnavn2").Range
Kundenavn.Text = Me.TextBox1.Value
Set Kundenavn = ActiveDocument.Bookmarks("selskabsnavn3").Range
Kundenavn.Text = Me.TextBox1.Value
Dim Adresse As Range
Set Adresse = ActiveDocument.Bookmarks("adresse").Range
Adresse.Text = Me.TextBox2.Value
Set Postnr = ActiveDocument.Bookmarks("postnr").Range
Postnr.Text = Me.TextBox3.Value
Dim by As Range
Set by = ActiveDocument.Bookmarks("by").Range
by.Text = Me.TextBox4.Value
Dim CVRnummer As Range
Set CVRnummer = ActiveDocument.Bookmarks("cvr").Range
CVRnummer.Text = Me.TextBox5.Value
Dim senesteaccept As Range
Set senesteaccept = ActiveDocument.Bookmarks("senesteaccept").Range
senesteaccept.Text = Me.TextBox6.Value
Dim underskriftdato As Range
Set underskriftdato = ActiveDocument.Bookmarks("dato").Range
underskriftdato.Text = Me.TextBox7.Value
Dim bestyrelsesmedlem1 As Range
Set bestyrelsesmedlem1 = ActiveDocument.Bookmarks("bestyrelse1").Range
bestyrelsesmedlem1.Text = Me.TextBox8.Value
Dim bestyrelsesmedlem2 As Range
Set bestyrelsesmedlem2 = ActiveDocument.Bookmarks("bestyrelse2").Range
bestyrelsesmedlem2.Text = Me.TextBox9.Value
Dim bestyrelsesmedlem3 As Range
Set bestyrelsesmedlem3 = ActiveDocument.Bookmarks("bestyrelse3").Range
bestyrelsesmedlem3.Text = Me.TextBox10.Value
Need code here
Me.Repaint
UserForm1.Hide
End Sub
Thanks for any assistance.
Kristoffer