Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-20-2021, 05:56 PM
Onison Onison is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Novice
Sequential Numbering of Word Doc
 
Join Date: Apr 2021
Posts: 9
Onison is on a distinguished road
Unhappy Sequential Numbering of Word Doc


I am trying to get a document to print with sequential numbers, but I am having no luck. At the moment I am manually entering the number after printing, I want to able to do this before the document prints, ideally remembering the last number printed as well.
I have tried some of the suggestions in other posts but nothing is working the way its supposed to. Any help would be greatly appreciated.
Reply With Quote
  #2  
Old 04-20-2021, 07:41 PM
macropod's Avatar
macropod macropod is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Quote:
Originally Posted by Onison View Post
I have tried some of the suggestions in other posts but nothing is working the way its supposed to.
Since you haven't told us what those posts are or how they are not working the way you want, it's pretty difficult to know how to meet your needs.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-20-2021, 07:57 PM
Onison Onison is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Novice
Sequential Numbering of Word Doc
 
Join Date: Apr 2021
Posts: 9
Onison is on a distinguished road
Default

Hello Macropod, I have used the Macro from https://www.msofficeforums.com/word-...numbering.html you provided previously;

Code:
Sub CertificatePrint()
Dim iStart As Integer, iEnd As Integer, i As Integer, StrArry
On Error GoTo ErrHandler
iStart = CInt(InputBox("What is the first Certificate to print?", "Print Certificates From", "1"))
iEnd = CInt(InputBox("What is the last Certificate to print?", "Print Certificates To", iStart + 1))
If iStart = 0 Or iStart > iEnd Then Exit Sub
With ActiveDocument
  For i = iStart To iEnd Step 2
    With .Shapes(2).TextFrame.TextRange.Fields(2)
      StrArry = Split(.Code.Text, " ")
      .Code.Text = Replace(.Code.Text, StrArry(UBound(StrArry)), i)
      .Update
    End With
    With .Shapes(2).TextFrame.TextRange.Fields(2)
      StrArry = Split(.Code.Text, " ")
      .Code.Text = Replace(.Code.Text, StrArry(UBound(StrArry)), i + 1)
      .Update
    End With
    .PrintOut
  Next
End With
ErrHandler:
End Sub

I manage to get as far as the dialogue box asking me the first & last numbers to print, but the number does not populate in the text box I want it to, or any other for that matter. Also, once the range has been selected it does not send the document to the printer.
Reply With Quote
  #4  
Old 04-20-2021, 08:07 PM
macropod's Avatar
macropod macropod is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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 different from that in the thread from which you sourced it.

Your implementation of the code attempts to look in the second textbox in the document and update the second field in that textbox.

I suspect nothing is being sent to the printer because the code fails before it gets that far - if for no other reason than because your document lacks a second field in the second textbox.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 04-20-2021, 09:15 PM
Onison Onison is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Novice
Sequential Numbering of Word Doc
 
Join Date: Apr 2021
Posts: 9
Onison is on a distinguished road
Thumbs up

The text box I am trying to populate is Text box 2 (I found this on the selection pane) I have just tried to change the Field source for the text by first changing the number to '3' after the text 'JHA #" with no luck, I then removed the text altogether and changed the number to '1' & '0' with no luck either. I'm not sure if you can tell, but I am totally new to this and have just been butchering my way through this trying to work out how they work. Appreciate the help Macro.
Reply With Quote
  #6  
Old 04-20-2021, 09:20 PM
macropod's Avatar
macropod macropod is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Without actually seeing the problem document, it can be difficult for anyone to diagnose the issue. Can you attach a document to a post with some representative data (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 04-20-2021, 09:35 PM
Onison Onison is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Novice
Sequential Numbering of Word Doc
 
Join Date: Apr 2021
Posts: 9
Onison is on a distinguished road
Default

https://www.msofficeforums.com/attac...1&d=1618979677
Attached Files
File Type: zip JHA Rev 14 Breight Tracked 1.zip (597.2 KB, 7 views)
Reply With Quote
  #8  
Old 04-20-2021, 09:57 PM
macropod's Avatar
macropod macropod is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

There appears to be only one textbox in your document for the number output, and it lacks the required field. Its index # is 57.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 04-20-2021, 11:45 PM
Onison Onison is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Novice
Sequential Numbering of Word Doc
 
Join Date: Apr 2021
Posts: 9
Onison is on a distinguished road
Default

Now I'm completely confused. How do I change it to the Text box on the first page, the one sitting under the title section? Can I put it in the header section under the Breight logo?
Reply With Quote
  #10  
Old 04-20-2021, 11:58 PM
macropod's Avatar
macropod macropod is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

The textbox you refer to has the index #57 - presumably because it's the 57th shape object you've inserted into the document body. Hence, you'd refer to it as .Shapes(57).

And, yes, you could put it in the header, but then you'd refer to it by its header shape index #. If you're going to do that, you might put some text in the textbox like:
"Copy #: "
(without the quotes) and use the following version of the macro:
Code:
Sub JHA_Print()
Dim iStart As Long, iEnd As Long, i As Long
On Error GoTo ErrHandler
iStart = CInt(InputBox("What is the first Certificate to print?", "Print Certificates From", "1"))
iEnd = CInt(InputBox("What is the last Certificate to print?", "Print Certificates To", iStart + 1))
If iStart = 0 Or iStart > iEnd Then Exit Sub
With ActiveDocument
  For i = iStart To iEnd
    With .Sections.First.Headers(wdHeaderFooterPrimary)
      .Shapes(.Shapes.Count).TextFrame.TextRange.Words.Last.Text = i
    End With
    .PrintOut
  Next
End With
ErrHandler:
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 04-21-2021, 01:35 AM
Onison Onison is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Novice
Sequential Numbering of Word Doc
 
Join Date: Apr 2021
Posts: 9
Onison is on a distinguished road
Default

How did you find the index for the text box?
I am looking in the selection pane and i cant see text box #57.
Reply With Quote
  #12  
Old 04-21-2021, 01:49 AM
macropod's Avatar
macropod macropod is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Quote:
Originally Posted by Onison View Post
How did you find the index for the text box?
I am looking in the selection pane and i cant see text box #57.
By testing shape index #s with a loop in VBA.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 04-21-2021, 01:51 AM
Onison Onison is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Novice
Sequential Numbering of Word Doc
 
Join Date: Apr 2021
Posts: 9
Onison is on a distinguished road
Default

Do you have it working on your end?
Reply With Quote
  #14  
Old 04-21-2021, 01:59 AM
macropod's Avatar
macropod macropod is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Of course!
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 04-21-2021, 02:10 AM
Onison Onison is offline Sequential Numbering of Word Doc Windows 10 Sequential Numbering of Word Doc Office 2016
Novice
Sequential Numbering of Word Doc
 
Join Date: Apr 2021
Posts: 9
Onison is on a distinguished road
Default

I have put the new code in, drawn a new text box in the header section and still no joy.
What am I missing? (apart from my brain)

Last edited by macropod; 04-21-2021 at 07:47 PM.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sequential numbering in Word - Unique numbers for table rows krips Word 1 03-21-2018 05:06 AM
Sequential numbering within Word Earthly Way Word VBA 1 12-02-2015 07:36 PM
New to Word VBA - Sequential Numbering techmendz Word VBA 11 08-07-2014 08:20 AM
Sequential Numbering of Word Doc Sequential Numbering jdwoods Word VBA 7 12-16-2011 05:11 AM
Sequential Numbering of Word Doc 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 07:14 AM.


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