Working with bookmarks

T

Terry

I want to open a specified document, check whether the hidden bookmark
_Toc69698351 exists
If it exists append the bookmark name to a string as part of a hyperlink
If it does not exist check whether the non hidden bookmark "KeyFindings"
exists
If this exists append it to the document filename as the sub-address of the
document
If it doesn't exist find the words "Key Findings" as the full text of a
paragraph and make this a new bookmark.

The answer to CowGirl partly answers the question but first I need to open
the document. Here is what I have so far:

Dim appWord As Word.Application
Dim wrdDoc As Word.Document
Dim wrdBookmark As Word.Bookmark

Set appWord = CreateObject("Word.Application")
appWord.Documents.Add
appWord.Documents.Open (sFile)

On Error Resume Next
wrdDoc.Bookmarks("_Toc69698351").Select
If Err Then
'The bookmark was not found
On Error Resume Next
wrdDoc.Bookmarks("KeyFindings").Select
If Err Then
'Can we find the heading
wrdDoc.Content.Find.Execute "Key Findings", False, True
???
Else
gsKeyFindings = sFile & "#KeyFindings"
End If
Else
gsKeyFindings = sFile & "#_Toc69698351"
End If
End If
The Word document is not opening correctly
TIA
Terry
 
D

Doug Robbins

Use

Dim appWord As Word.Application
Dim wrdDoc As Word.Document
Dim wrdBookmark As Word.Bookmark

Set appWord = CreateObject("Word.Application")
Set wrdDoc = appWord.Documents.Open (sFile)


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top