test for error returned by TOC field code

喜夏-厌秋 提交于 2021-01-28 08:00:54

问题


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"} = "No table of figures entries found." " No table" "Entries exist"}

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 :-) )

thanks.

Carl


回答1:


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 "Figure"} = " No table of figures entries found." " No table" "Entries exist"}



来源:https://stackoverflow.com/questions/10482704/test-for-error-returned-by-toc-field-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!