The last thing you need is a script.
When you want to make your TOC, go to Pages, Numbering and Section Options, and put a section prefix in like 1- for each section (both 1 and 2 in your case). Click "Include Prefix When Numbering Pages".
Then make your TOC.
It will have all the section prefixes. ("1-1", "2-2-4", examples)
Now just change the Numbering and Section Options BACK to your pre-TOC defaults. As long as you don't update the TOC under Layout/Update TOC, your TOC text will contain the prefix, but your page numbers will look normal. If you have to change the text in the TOC for any reason, do it manually.
Let me know if that works.
Thank you for your suggestion. At least one person responded.
However, this is will not work for our situation.
I have an alternate method, but it is not the best. The suggestion you present means altering documents that already approved. I would either have to work from duplicate documents or recheck each document in the book after the TOC is done. Either way, I still have to do a search and replace (which is working for us, but I'd like to script that step).
I'll let you know more soon.
Sounds like you need a GREP find and replace solution. I only use it on basic level to style my docs. O'Reilly has a guide to ID and GREP. Hope you are technical. If you could set up your toc to have different stylenames for each section, then you'd just search for a string like "/d+|/d+-/d+" (one or more digits OR one or more digits hyphen one or more digits (example: 22 or 23-25) whose paragraph style is "that paragraph style", replace with "1-$0" , which should give you 1-22, or 1-23-25.
I'm a newbie at GREP, so if this is the way you want to go, you should repost this question as a GREP question.
That's the best I can do. Good luck.
Thanks again for your reply.
As I mentioned, I have an alternative method which is not the most desirable (which you touch on in your last reply "different stylenames for each section"). However that has other inherent challanges.
Our programmer here at work has just provided me with the script I need. I am test it now, but it appears to work great. I may post it here in the future if he has no objections.
You have a programmer? How lucky is that. My company is run by luddites (I basically have to sneak my scripting/xml/grep solutions in off hours).
Anyway, I'd really like it if you could share that script on this post.
Once again, good luck.
Thanks again for your reply.
He's not "my" programmer. He works at our company and is very, very smart. (I think he belongs to his spose:)).
I am trying to learn scripting. I have included some basic GREP in our styles and they word well.
Anyway. I am testing the script now, and when I am sure it does not error out, I will post for other. I hope to submit a tutorial on how we do our TOC in the near future.