![]() |
|
|||||||
|
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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] |
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
||||
|
||||
|
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 |
|
|
|
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 |
How to have sequential numbers appear in word header
|
woodyear99 | Word | 1 | 07-18-2016 08:28 PM |