Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-11-2024, 09:36 AM
gmaxey gmaxey is offline Macro for enyone and everyone TOC based on FN Windows 10 Macro for enyone and everyone TOC based on FN Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Susan,


If your friend is charging for every line of code then in my humble opinion, you were overcharged a bit. Yes, a TC field isn't picked up as you would expect. However, that doesn't mean there. Put TC fields in your footnotes and try:


Code:
Sub CreateTOCofFootnotes_CurrentSection()
Dim oSec As Section
Dim colTCFields As New Collection
  Set oSec = ActiveDocument.Sections(Selection.Information(wdActiveEndSectionNumber))
  ScanSectionFootNotes oSec, colTCFields
  InsertTableOfContents colTCFields
lbl_Exit:
  Exit Sub
End Sub

Sub InsertTableOfContents(colTCFields As Collection)
Dim oRng As Range
Dim lngIndex As Long
Dim strEntry As String
  For lngIndex = 1 To colTCFields.Count
    Set oRng = colTCFields(lngIndex).Code
    strEntry = Right(oRng.Text, Len(oRng.Text) - 5)
    Selection.TypeText strEntry & " - " & oRng.Information(wdActiveEndAdjustedPageNumber) & vbCr
  Next lngIndex
lbl_Exit:
  Exit Sub
End Sub

Sub ScanSectionFootNotes(oSec As Section, colTCFields As Collection)
Dim oFN As Footnote
Dim oField As Field
  For Each oFN In oSec.Range.Footnotes
    For Each oField In oFN.Range.Fields
      If oField.Type = wdFieldTOCEntry Then
        colTCFields.Add oField
      End If
    Next oField
  Next oFN
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to find a header based on a value in another cell Tphil413 Excel Programming 2 07-23-2019 09:59 AM
Macro to insert an image based as told puff Word VBA 1 05-24-2018 03:55 PM
a macro that can copy data from copy.xls to our current excel macro.xls based on criteria: udhaya Excel Programming 1 11-12-2015 10:12 AM
Macro for enyone and everyone TOC based on FN Formatting Macro based on Zoom (PageScale) thundercats9595 Excel Programming 6 02-06-2014 09:49 PM
Macro based on cell value ubns Excel Programming 1 05-07-2012 04:03 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:24 AM.


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