Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2021, 12:50 AM
powermetal114 powermetal114 is offline The last page number of a heading in TOC Windows 7 64bit The last page number of a heading in TOC Office 2010 64bit
Novice
The last page number of a heading in TOC
 
Join Date: Aug 2018
Posts: 4
powermetal114 is on a distinguished road
Default The last page number of a heading in TOC

Hi everybody,




I wish you all a great day first.


If you insert a TOC you'll get always the beginning page number of a specific heading.



Is there any way to have a TOC always with the end page number of that heading also.


What I wish to have you can finde in the attachement.


Thank you all.


Regards
PM114
Attached Files
File Type: docx example.docx (18.6 KB, 5 views)
Reply With Quote
  #2  
Old 02-12-2021, 01:25 AM
macropod's Avatar
macropod macropod is offline The last page number of a heading in TOC Windows 10 The last page number of a heading in TOC 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 powermetal114 View Post
If you insert a TOC you'll get always the beginning page number of a specific heading.



Is there any way to have a TOC always with the end page number of that heading also.
In a word, no.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 02-12-2021, 01:30 AM
powermetal114 powermetal114 is offline The last page number of a heading in TOC Windows 7 64bit The last page number of a heading in TOC Office 2010 64bit
Novice
The last page number of a heading in TOC
 
Join Date: Aug 2018
Posts: 4
powermetal114 is on a distinguished road
Default

Is there any way to do it by VB?
Reply With Quote
  #4  
Old 02-12-2021, 02:12 AM
macropod's Avatar
macropod macropod is offline The last page number of a heading in TOC Windows 10 The last page number of a heading in TOC 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

Would it be possible to get the ending page number for each heading via VBA? Yes.

Could that ending page number be added a TOC field's output? No.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 02-12-2021, 02:21 AM
powermetal114 powermetal114 is offline The last page number of a heading in TOC Windows 7 64bit The last page number of a heading in TOC Office 2010 64bit
Novice
The last page number of a heading in TOC
 
Join Date: Aug 2018
Posts: 4
powermetal114 is on a distinguished road
Default

unless one creates the whole TOC also in the same VB-Code, right?
Reply With Quote
  #6  
Old 02-12-2021, 02:25 AM
macropod's Avatar
macropod macropod is offline The last page number of a heading in TOC Windows 10 The last page number of a heading in TOC 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

If you want to create your own version of a TOC, that's fine, But then it wouldn't employ a TOC field and wouldn't behave as one. If you want to do down that path, see:
https://www.msofficeforums.com/113050-post2.html
https://www.msofficeforums.com/157443-post6.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 02-12-2021, 02:14 PM
Guessed's Avatar
Guessed Guessed is offline The last page number of a heading in TOC Windows 10 The last page number of a heading in TOC Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You can add a TC field to the end of every heading and then build the TOC using those fields. Its a very rarely used method of building a TOC but I think it would work for your requirement
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #8  
Old 02-13-2021, 01:10 AM
macropod's Avatar
macropod macropod is offline The last page number of a heading in TOC Windows 10 The last page number of a heading in TOC 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

Hi Andrew,

I can't see how that would produce a TOC with entries like:

Code:
1. Some Heading................................................ 1-5
1.1 Some Sub-Heading........................................... 5-9
2. Another Heading........................................... 10-11
or, depending on what 'last page' reference the OP requires:
Code:
1. Some Heading................................................ 1-9
1.1 Some Sub-Heading........................................... 5-9
2. Another Heading........................................... 10-11
etc., let alone have those entries update to reflect edits to the document.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 02-13-2021, 04:06 AM
Guessed's Avatar
Guessed Guessed is offline The last page number of a heading in TOC Windows 10 The last page number of a heading in TOC Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Ahh, if that is what the poster meant then it is certainly more complicated than I would ever bother working with...

But I think it can still be done with nested ref codes in TC field. Say you bookmark the heading text with the bookmark name 'head1'. Then add a TC field where you want that section's pages to end (ie. in the last paragraph of that section)
{TC "{Ref head1 \n} {Ref head1} {PageRef head1}-{Page}" \l 1 \n}

Then build the TOC using the \f switch to bring in the TC fields.

This works as a concept and could be coded into a macro but it is so ungainly that it is easier to just build the actual tc text on the fly with a macro and forget trying to use the nested fields.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #10  
Old 02-13-2021, 04:14 AM
macropod's Avatar
macropod macropod is offline The last page number of a heading in TOC Windows 10 The last page number of a heading in TOC 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

In which case, the OP would do just as well to use a macro from one of the links I pasted and add to the output the last page # of each '\HeadingLevel' bookmark.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 02-15-2021, 05:59 AM
Stefan Blom's Avatar
Stefan Blom Stefan Blom is offline The last page number of a heading in TOC Windows 10 The last page number of a heading in TOC Office 2019
Moderator
 
Join Date: Aug 2011
Posts: 3,872
Stefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to all
Default

Of course, creating a TOC that displays ranges of page numbers would be unusual. Why is it required for this document?
__________________
Stefan Blom
Microsoft Word MVP

Microsoft 365 apps for business
Windows 11 Professional
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Table of contents puts page number next to heading redyar Word 2 06-18-2020 09:33 AM
Can I create a page number from a non-Heading style? techwriter3k Word 9 09-25-2019 06:58 AM
Page number with chapter number but not from Heading 1 alpruett Word 5 06-04-2014 02:00 PM
Control the size of space between heading number and heading text Dr Wu Word 1 07-17-2013 12:24 PM
Page number picking up heading numbering?! Ulodesk Word 0 09-24-2009 01:56 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:23 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