Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-16-2023, 06:08 AM
TallTrees TallTrees is offline Get paragraph number from multlilevel list style for use in TC field Windows 10 Get paragraph number from multlilevel list style for use in TC field Office 2021
Novice
Get paragraph number from multlilevel list style for use in TC field
 
Join Date: Jul 2022
Posts: 8
TallTrees is on a distinguished road
Default Get paragraph number from multlilevel list style for use in TC field

Hi,



I am trying to insert a TC marker as part of a macro. It is inserting the TC marker correctly with the text I want but unfortunately doesn't seem to pick up the number which is applied to the current paragraph.

The parapraph that I am applying my macro to is using a style which is in a multilevel list and has number '1' set. I followed Shauna's guide for setting up the numbering and it works really well.



As an example it looks like this (with proper alignment!)

Code:
1    Some text here 
  2    Some more text
Desired output is something like this if I was to run the macro at the first paragraph:

Code:
1    Some text here { TC "1   Some Text here" \f C \l "1" }
  2    Some more text

What I actually get is (note the omission of the '1')



Code:
1    Some text here { TC "Some Text here" \f C \l "1" }
 2    Some more text

Some code with comments may help to explain a bit more:

Code:
Dim myRange As Range
myRange = Selection.Paragraphs(1).Range
Dim thisPara as String
Dim currentNumber as String
Dim spaceChar as String
Dim tcText as String
spaceChar = " "

' This is the current paragraph's text
thisPara = myRange 

' I expected to be able to get the current number using the line below. But it's always blank. It doesn't even return "nothing" like the documentation says it should. I've tried calling it directly as well (e.g Selection.Paragraphs(1).Range.ListFormat.ListString)
currentNumber = myRange.ListFormat.ListString 

' Some concatenation...
tcText = currentNumber & spaceChar & thisPara

 ActiveDocument.TableOfContents.MarkEntry Range:=myRange, Entry:=tcText, Level:=1
It seems that the Range.ListFormat.ListString is empty. Before trying to use this I was attempting to just select the current paragraph, hoping it'd also grab the number, but it just finds the text of the paragraph.


Does anyone know what I am doing wrong? Happy to provide more information if needed but I think there is enough information in my post.

Thanks
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get paragraph number from multlilevel list style for use in TC field Count number of periods and convert paragraph to a heading style jeffreybrown Word VBA 7 10-19-2019 01:15 PM
Get paragraph number from multlilevel list style for use in TC field How do I create a field that will return the current paragraph number minus one in an automatic list gugootz Word 1 11-23-2015 04:58 PM
Get paragraph number from multlilevel list style for use in TC field List Style Numbering picks up out of order number from LATER list spthomas Word 12 12-16-2013 05:23 PM
Get paragraph number from multlilevel list style for use in TC field Trouble on Using List number style in Master Document nattasiray Word 2 12-16-2011 08:01 PM
Numbered List paragraph style prints out incorrectly when converted to PDF - Help! kimrussell68 Word 0 02-02-2010 07:58 AM

Other Forums: Access Forums

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