- Local time
- Today, 07:45
- Joined
- Feb 28, 2001
- Messages
- 28,971
Scenario: A word document contains some things that I might need to reference from time to time. As a "help" feature I have a way to open that document from Access. (This part works.) I have bookmarks all through the document that represent the things that might need to be referenced. So I try to go to the bookmark. (This part also works.)
What doesn't work is that the bookmark comes out at the bottom of the screen in which the Word document opens. I wanted it at the top.
The above sample fails on the .ScrollIntoView part. Everything else works. Has anyone else used something like this before? The goal is to bring the bookmark to the top left of the active window. I've tried other variants of this puppy, this is just the latest iteration.
What doesn't work is that the bookmark comes out at the bottom of the screen in which the Word document opens. I wanted it at the top.
Code:
Public Sub OpenHow2Help(oWd As Word.Application, sBkMk As String)
Dim sBEFS As String 'file spec of the back-end file
Dim bGotIt As Boolean 'slot for return of the OPEN call
Dim wdActive As Word.Document 'selector for the word document
Dim vBkMk As Variant 'word, inexplicably, likes variants
vBkMk = sBkMk
sBEFS = WhereIsTable("tHLPREFS") 'get location of the back end file
sWrdHow2File = FindFileDev(sBEFS) & FindFileDir(sBEFS) & "\HOW2.DOCX"
OpenWordRO oWd, sWrdHow2File, bGotIt 'try to open the object
If bGotIt Then
oWd.Documents(sWrdHow2File).Activate
If ActiveDocument.Bookmarks.Exists(sBkMk) = True Then
ActiveDocument.Bookmarks(vBkMk).Select
ActiveDocument.GoTo What:=wdGoToBookmark, Name:=vBkMk
ActiveDocument.Windows(1).ScrollIntoView ActiveDocument.Bookmarks(sBkMk), True
End If
End If
End Sub
The above sample fails on the .ScrollIntoView part. Everything else works. Has anyone else used something like this before? The goal is to bring the bookmark to the top left of the active window. I've tried other variants of this puppy, this is just the latest iteration.