Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-23-2019, 12:19 PM
craznbran craznbran is offline Employ a single document in Word that will automatically insert sequential numbers in desired area Windows 10 Employ a single document in Word that will automatically insert sequential numbers in desired area Office 2010
Novice
Employ a single document in Word that will automatically insert sequential numbers in desired area
 
Join Date: Sep 2019
Posts: 2
craznbran is on a distinguished road
Cool Employ a single document in Word that will automatically insert sequential numbers in desired area

I have tried everything. Forum after forum after video after dummy self help and I cannot seem to figure it out. I need to be able to print a single document x30 at a time where my PO# 1XXXX will automatically update sequentially. I have also read several forums on this website & I cannot seem to get my dang document to do what I need it to do. I have added a macro to my document, I have "ran" it... and nothing. I've even looked up Dummies guide to VBA & macros and I cannot seem to understand what it is that I am doing wrong...



My template is already made out & I have the following Macro tied/saved to my document. My guess is, that in the macro, I am not telling it correctly where to pull the number from to start the 1st sequential order. Once I can figure it out, I will be using this document as a base template & will need to copy/save as new for other PO# types for various suppliers we use. So as user friendly as possible so that others on my team can update the PO# & print as well. I am on the most updated version of Microsoft Word for Office 365 MSO 64-bit. Please save me from insanity
Code:
Option Explicit

Sub CertificatePrint()
Dim iStart As Integer, iEnd As Integer, i As Integer
On Error GoTo ErrHandler
With ActiveDocument.Shapes(1).TextFrame.TextRange.Fields(1)
  iStart = CInt(InputBox("What is the first Certificate to print?", _
      "Print Certificates From", Split(Split(.Code.Text, " ")(0), "=")(1)))
  iEnd = CInt(InputBox("What is the last Certificate to print?", _
      "Print Certificates To", iStart))
  If iStart = 0 Or iStart > iEnd Then Exit Sub
  For i = iStart To iEnd
    If i = iStart Then
      With Application.Dialogs(wdDialogFilePrint)
        If .Show = 0 Then Exit Sub
      End With
    End If
    .Code.Text = "=" & i & " \# 0"
    .Update
    ActiveDocument.PrintOut
  Next
End With
ErrHandler:
End Sub

Last edited by macropod; 10-23-2019 at 09:58 PM. Reason: Added code tags
Reply With Quote
  #2  
Old 10-23-2019, 10:02 PM
macropod's Avatar
macropod macropod is offline Employ a single document in Word that will automatically insert sequential numbers in desired area Windows 7 64bit Employ a single document in Word that will automatically insert sequential numbers in desired area Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your code is from https://www.msofficeforums.com/word-...numbering.html. There's even a demo document in post #7 in that thread and another in post #11 - along with all the instructions one might need.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-25-2019, 05:44 PM
craznbran craznbran is offline Employ a single document in Word that will automatically insert sequential numbers in desired area Windows 10 Employ a single document in Word that will automatically insert sequential numbers in desired area Office 2010
Novice
Employ a single document in Word that will automatically insert sequential numbers in desired area
 
Join Date: Sep 2019
Posts: 2
craznbran is on a distinguished road
Default

Yes, this post is the one that I have found to be most helpful. That is why I've been reading up & trying to teach myself Macros as I cannot understand why I am unable to get it to work. Ive been on multiple "macros for dummies" sites/tutorials because I just honestly believe that I am just not applying it correctly.
Reply With Quote
  #4  
Old 10-25-2019, 09:01 PM
gmayor's Avatar
gmayor gmayor is offline Employ a single document in Word that will automatically insert sequential numbers in desired area Windows 10 Employ a single document in Word that will automatically insert sequential numbers in desired area Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If you cannot get Paul's working example to work - how about a solution with no programming required - Auto number documents - though there are macros included on that page also?
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having Word print sequential serial numbers in a text field limdul9992 Word VBA 5 08-21-2019 06:23 AM
with different area of blocks, can we arrange automatically in a big rectangle area, Optimally oneeyeevil Excel Programming 0 06-21-2019 03:45 AM
Sequential numbering in Word - Unique numbers for table rows krips Word 1 03-21-2018 05:06 AM
Automatically generate formulas from just the row numbers (auto insert the column) knewman Excel 14 04-25-2017 11:54 PM
Employ a single document in Word that will automatically insert sequential numbers in desired area How to have sequential numbers appear in word header woodyear99 Word 1 07-18-2016 08:28 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:18 PM.


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