Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-24-2016, 05:40 AM
urbandekay urbandekay is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2007
Novice
Hyperlink in Table of contents
 
Join Date: Mar 2016
Posts: 12
urbandekay is on a distinguished road
Default Hyperlink in Table of contents

Hi, is there anyway to link word count of individual chapters into a ToC?

Or failing that some means to effect a table that reports the word count in each chapter



thanks
Reply With Quote
  #2  
Old 03-24-2016, 09:02 AM
macropod's Avatar
macropod macropod is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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 urbandekay View Post
Hi, is there anyway to link word count of individual chapters into a ToC?
Not unless you put each chapter into a separate document.
Quote:
Originally Posted by urbandekay View Post
Or failing that some means to effect a table that reports the word count in each chapter
It could be done with a macro - provided each chapter can be differentiated by something such as a Section break.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 03-24-2016, 09:40 AM
urbandekay urbandekay is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2007
Novice
Hyperlink in Table of contents
 
Join Date: Mar 2016
Posts: 12
urbandekay is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Not unless you put each chapter into a separate document.

It could be done with a macro - provided each chapter can be differentiated by something such as a Section break.
Ok lets say each is seperated by a section break how then?
Reply With Quote
  #4  
Old 03-24-2016, 10:27 AM
macropod's Avatar
macropod macropod is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

As I said, with a macro. For example, the following macro will output a word-count for each Section at the end of the document.
Code:
Sub Demo()
Dim Sctn As Section, StrCounts As String
With ActiveDocument
  For Each Sctn In .Sections
    StrCounts = StrCounts & "Section " & Sctn.Index & ":" & vbTab & _
      Sctn.Range.ComputeStatistics(wdStatisticWords) & vbCr
  Next
  .Range.InsertAfter StrCounts
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 03-24-2016, 10:58 AM
urbandekay urbandekay is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2007
Novice
Hyperlink in Table of contents
 
Join Date: Mar 2016
Posts: 12
urbandekay is on a distinguished road
Default

Hi, thanks for that but when I run this it outputs the word count only of the final section, regardless of where the curser is, am I doing something wrong?
Reply With Quote
  #6  
Old 03-24-2016, 01:58 PM
macropod's Avatar
macropod macropod is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

I subsequently edited the code - try it now.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 03-25-2016, 04:24 AM
urbandekay urbandekay is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2007
Novice
Hyperlink in Table of contents
 
Join Date: Mar 2016
Posts: 12
urbandekay is on a distinguished road
Default

Thanks that works well but how do I know link those figures into my ToC
Reply With Quote
  #8  
Old 03-25-2016, 04:48 AM
macropod's Avatar
macropod macropod is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

You can't (unless you include them in headings referenced by the TOC) - and why would you want to?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 03-25-2016, 07:28 AM
urbandekay urbandekay is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2007
Novice
Hyperlink in Table of contents
 
Join Date: Mar 2016
Posts: 12
urbandekay is on a distinguished road
Default

Thanks again, one last question if I may, how do I create that heading in the ToC?
As to why, it is useful to me or it delays me getting on with what I should be doing
Reply With Quote
  #10  
Old 03-25-2016, 02:21 PM
macropod's Avatar
macropod macropod is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

You could simply apply an appropriate heading Style to the macro's output, then update the TOC by clicking anywhere in it and pressing F9
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 03-25-2016, 02:27 PM
urbandekay urbandekay is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2007
Novice
Hyperlink in Table of contents
 
Join Date: Mar 2016
Posts: 12
urbandekay is on a distinguished road
Default

Ok, so as I understand it I find what part of the macro is the output, which I presume I can do by trial and error and then tell it to be say, subtitle? As you can no doubt tell, I know nothing of these things you call macros, though I did change yours slightly to make it output at the top of the document rather than the bottom but that was just guess work
Reply With Quote
  #12  
Old 03-25-2016, 03:18 PM
macropod's Avatar
macropod macropod is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

I wasn't suggesting you make any modifications to the macro; only that you format the output that it has placed at the end of your document with an appropriate heading Style. Do note, too, that every time you run the macro, it will output a new set of stats. It won't delete any previous stats - which will get counted in the new total for the last Section.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 03-25-2016, 03:33 PM
urbandekay urbandekay is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2007
Novice
Hyperlink in Table of contents
 
Join Date: Mar 2016
Posts: 12
urbandekay is on a distinguished road
Default

Oh, I see, is there not a way to instruct the macro to do the formatting?
Reply With Quote
  #14  
Old 03-25-2016, 03:43 PM
macropod's Avatar
macropod macropod is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

Sure one could, but that isn't what you had asked for. All you asked for originally was how to get the counts. I gave you a simple macro for that because I had no idea what you wanted to do with them after they were generated. For all I knew, you wanted to read & delete them or attach them to your actual headings.

I still don't see the point in generating this kind of stuff with a macro when you can get the word count for any range you're interested in just by selecting the range and looking at the word count stats on the status bar. That said, try:
Code:
Sub Demo()
Dim Sctn As Section, StrCounts As String, Rng As Range, TOC As TableOfContents
With ActiveDocument
  For Each Sctn In .Sections
    StrCounts = StrCounts & "Section " & Sctn.Index & ":" & vbTab & _
      Sctn.Range.ComputeStatistics(wdStatisticWords) & vbCr
  Next
  Set Rng = .Characters.Last
  With Rng
    .InsertAfter StrCounts
    .End = .End - 1
    .Style = wdStyleHeading2
  End With
  For Each TOC In .TablesOfContents
    TOC.Update
  Next
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 03-25-2016, 03:56 PM
urbandekay urbandekay is offline Hyperlink in Table of contents Windows 7 64bit Hyperlink in Table of contents Office 2007
Novice
Hyperlink in Table of contents
 
Join Date: Mar 2016
Posts: 12
urbandekay is on a distinguished road
Default

Yep, that works, many thanks
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink in Table of contents Move table cell contents from one table to another table or cell in same table donaldadams1951 Word VBA 4 02-04-2015 03:54 PM
Hyperlink in Table of contents Table with Table of Contents as a Column dynamictiger Word Tables 4 07-21-2014 10:16 PM
Table of Contents feature Word 10 04-09-2013 05:45 AM
Hyperlink in Table of contents Table of Contents ep2002 Word 4 06-20-2012 10:23 PM
Table of contents markos97 Word 0 10-26-2010 08:52 AM

Other Forums: Access Forums

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