Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-24-2024, 02:37 AM
Laurel Laurel is offline TOC with IF Condition Windows 10 TOC with IF Condition Office 2021
Novice
TOC with IF Condition
 
Join Date: Oct 2024
Posts: 2
Laurel is on a distinguished road
Angry TOC with IF Condition

Hello, a question about tables of contents with if conditions.

I have a document with chapters and subchapters. The document has two tables of contents: a short one (only the main heading) and a detailed one (with headings and page numbers). Now I want to ensure that the second detailed table of contents is not output if the short and detailed ones match.


I have the following field code:


{if {\TOC \t "Heading 2;1" \b inh_kap0_2 \o "2-2" \n "1-1" } =
{\TOC \t "Heading 2;1;Heading 3;2" \b inh_kap0_2 \o "2-3" \n "1-1" } "" {\TOC \t "Heading 2;1;Heading 3;2" \b inh_kap0_2 \o "2-3"
\n "1-1" \* mergeformat}}


This works very well. Now I would like to create a detailed and linked table of contents. But, if I add the \h switch, so


{if {\TOC \t "Heading 2;1" \b inh_kap0_2 \o "2-2" \n "1-1" } =


{\TOC \t "Heading 2;1;Heading 3;2" \b inh_kap0_2 \o "2-3" \n "1-1" } "" {\TOC \h \t "Heading 2;1;Heading 3;2" \b inh_kap0_2 \o "2-3"
\n "1-1" \* mergeformat}}


There is still no link.

I read that in \toc fields with if conditions the \h doesn't work. Is there another way to do this anyway? To reach links in the table of contents? Or works that, if at all, only via VBA code?


Thank you for your support.
Laurel
Reply With Quote
  #2  
Old 10-24-2024, 04:45 AM
macropod's Avatar
macropod macropod is offline TOC with IF Condition Windows 10 TOC with IF Condition Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,379
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 you've discovered, the \h switch doesn't work inside an IF statement. I don't believe there's a field coding workaround for what you're trying to do.

A macro could be used to compare the two Tables of Contents and delete or hide the second one if they match, but that's probably about as far as you could go
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-24-2024, 06:12 AM
Laurel Laurel is offline TOC with IF Condition Windows 10 TOC with IF Condition Office 2021
Novice
TOC with IF Condition
 
Join Date: Oct 2024
Posts: 2
Laurel is on a distinguished road
Default

Thank you, Paul. Unfortunately that's not what I want. But I'll try.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
sumProduct with OR condition ShostyFan Excel 7 10-16-2019 02:19 PM
TOC with IF Condition If condition not working. jhansrod Word VBA 8 06-15-2019 05:59 AM
TOC with IF Condition How to use if condition to for this ... LearnerExcel Excel 1 12-19-2016 02:14 PM
TOC with IF Condition check with condition karti Word 2 03-15-2011 06:06 AM
Retrict Method Condition markp Outlook 0 12-22-2005 05:38 PM

Other Forums: Access Forums

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