测试 TOC 域代码返回的错误

测试 TOC 域代码返回的错误

问题描述:

我正在尝试在创建图表之前测试是否存在任何图表标题".我有一行代码可以工作:{IF {TOC \h \z \c "Figure"} = {TOC \h \z \c "blarghel"} "无表" "条目存在"}(当然是字段代码),其中blarghel"是一个故意的假人.我以为我曾经能够(在 Word 2003 中)引用返回的错误字符串,对于 WORD 2010 将是

I am trying to test whether any "figure captions" exist before I create a Table of Figures. I have a line of code that works: {IF {TOC \h \z \c "Figure"} = {TOC \h \z \c "blarghel"} " No table" "Entries exist"} (field codes, of course), where "blarghel" is a deliberate dummy. I thought I used to be able (in Word 2003) to quote the error string returned, which for WORD 2010 would be

{IF {TOC \h \z \c "Figure"} = "未找到图表条目表."" 无表" "条目存在"}

但这总是返回IF"测试的失败条件.我没有看到任何ISERROR"类型的域代码,也无法弄清楚 TOC 域代码实际返回的是什么.
有任何想法吗?(是的,通常我会用域代码替换第二个条件以返回数字表:-))

But that always returns the failure condition of the "IF" test. I don't see any "ISERROR" kind of field code, and can't figure out what the TOC field code is actually returning.
Any ideas? (and yes, normally I'd replace the second condition with the field code to return the table of figures :-) )

谢谢.

卡尔

我认为您需要在 Word 2010 中的错误消息之前添加一个额外的段落标记.这可能自 Word 2003 以来发生了变化 - 我没有检查过:

I think you need an extra paragraph mark before the error message in Word 2010. That may have changed since Word 2003 - I have not checked:

{IF {TOC \h \z \c "图"} = "未找到图表条目表." " 无表" "条目存在"}

{IF {TOC \h \z \c "Figure"} = " No table of figures entries found." " No table" "Entries exist"}