Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-06-2014, 05:55 AM
gmaxey gmaxey is offline New to Word VBA - Sequential Numbering Windows 7 32bit New to Word VBA - Sequential Numbering Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
New to Word VBA - Sequential Numbering How do I do a Sequential Numbering? gburya Word VBA 26 07-04-2017 03:29 PM
New to Word VBA - Sequential Numbering Sequential Document Numbering Geza59 Word VBA 18 01-15-2014 01:43 AM
New to Word VBA - Sequential Numbering Sequential page numbering im_rusahbh Word VBA 1 12-23-2013 05:28 PM
New to Word VBA - Sequential Numbering Sequential Numbering jdwoods Word VBA 7 12-16-2011 05:11 AM
New to Word VBA - Sequential Numbering Sequential Page Numbering of Multiple Word Docs bobmard Word 8 08-24-2011 08:51 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft