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
_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