So what I'd like to do is run a (vb)script that will match up those
ugly names to the text of the TOC entry. If myField is a vbscript/vba
field reference, then
myField.type: a numeric field type (88 => hyperlink, 37 => pageref, 9
=> TOC entry)
myField.code examples
Type 88: HYPERLINK \l "_Toc141442256"
Type 37: PAGEREF _Toc141442256 \h
Type 9: TC "Introduction " \f C \l "1"
How do I make the matchup from type 9 (TOCEntry) to the corresponding
pageref/hyperlink so that later I can insert my own page reference to
what the TOC Entry points at. In other words, I want to avoid creating
a separate bookmark, when there is already a TOC Entry pointing to a
place of interest.
Thanks,
Csaba Gabor from Vienna
PS. This is on Word 2003 under WinXP
"Csaba Gabor" <dan...@gmail.com> wrote in message
news:1153818597.9...@i3g2000cwc.googlegroups.com...
Jezebel,
thank you, Thank You, THANK YOU. I don't dabble in Word that much,
but I had thought to iterate through all the Bookmarks with a
For Each bm in doc.Bookmarks
but the _Toc guys did not show up. This is sort of in line with what I
get when I try to do an Insert \ Reference \ Cross-reference ...
sometimes those _Toc guys show up and sometimes they don't.
Thanks again,
Csaba
PHP code to return associative array of bookmarks:
function getBookmarks($doc) { // doc is a word document COM object
$abm = array(); // array of bookmarks
foreach ($doc->Fields as $ref) // TOC
if (preg_match("/_Toc\d+/",$ref->code,$aM))
$abm[$aM[0]] = $doc->Bookmarks($aM[0])->range->text;
foreach ($doc->Bookmarks as $bm) $abm[$bm->Name] = ""; // standard
return $abm; }
"sometimes those _Toc guys show up and sometimes they don't"
This is most likely related to the Hidden bookmarks check box that is on the
Bookmark dialog box. Also, if you don't have a TOC and TC entries, then Word
won't generate any hidden bookmarks for the TOC.
HTH,
Dave
"Csaba Gabor" <dan...@gmail.com> wrote in message
news:1153836510.7...@m73g2000cwd.googlegroups.com...