View Single Post
 
Old 08-06-2014, 05:55 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Private Sub cmdSubmit_Click()
Dim lngIndex As Long
Dim oRng As Word.Range
  With ActiveDocument
    .Bookmarks("NoOfBoxes").Range.Text = txtNoOfBoxes
    .Bookmarks("YearClosed").Range.Text = txtYearClosed
    .Bookmarks("CourtNumber").Range.Text = txtCourtNumber
    .Bookmarks("CaseName").Range.Text = txtCaseName
    .Sections.Add
    For lngIndex = 1 To txtNoOfBoxes
      Set oRng = ActiveDocument.Sections(2).Range
      oRng.Collapse wdCollapseEnd
      oRng.InsertBefore "Page " & lngIndex & " of " & txtNoOfBoxes
      oRng.Collapse wdCollapseEnd
      oRng.InsertBreak (wdPageBreak)
    Next lngIndex
  End With
  Unload Me
lbl_Exit:
  Exit Sub
End Sub
btw, as Paul suggested, you are not creating a template in VBA. Work.dotm is a template. You have created a rudimentary UserForm and with that Userform you are adding pages to the document created from Work.dotm
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote