Updating Word Bookmarks

DBL

Registered User.
Local time
Today, 20:35
Joined
Feb 20, 2002
Messages
659
I'm creating a word document from Access, using bookmarks, and save the document when it's first created. However, the user may then update the word document with additional information a the Access record with additional information. How can I get the bookmarks to refresh in the word document when the user clicks on the link to open the word document without erasing any additional information they've typed into the word document by hand?
 
If I'm reading the question right (which I'm not betting any money on), your question is merely whether the document exists or not? So do a file search (File Find) first and see if that document can be found. If it can, do the action you want for "file already exists and has bookmarks" - but if it can't, do the other action.

Or did I miss something?
 
Hi Doc Man

Sorry, it's me not explaining myself. Really all I want to be able to do is refresh the bookmarks with up to date data every time a user opens the created word document via the Access stored hyperlink, without loosing any data that they have entered mannually, outwith the bookmarks.

Hope that's clearer!

Dawn
 
OK, your issue is a combination of timing and other factors.

1. So the user opens the file via your hyperlink.... you have an OnClick event that fires BEFORE the file is opened. You have an opportunity to step into the file first before letting your user in. Or you can wait for the application to close before you update it.

2. But how do you know that the user did (or didn't do) anything to the file? (Rhetorical question). The trick is to know whether the updates you planned still apply.

3. And what do you do with the schmuck who opens the file without following the links first?
 
The process is this:

The user creates the record in the database, which may not have all the required information. They create an initial word report which takes over whatever information is available from the form and add any interpretation information that they have at that time - which isn't stored in the database, automatically saves the word document to a specific file path and name and stores the path in another field in the database. As other information comes in on the case they update the database but at the moment when they click on the word document file path, using GetFilePath, and the word document opens it's not refreshing the bookmarks with any additional information. They can only open the word document via the file path in the database, it's not available to them to open via Word.

The word document needs to update before they open the word document with the bookmark information.

I'm using the ObjWord to create and insert the initial bookmark information but don't know how to refresh that information should anything change in the database.
 
I'm using the ObjWord to create and insert the initial bookmark information but don't know how to refresh that information should anything change in the database.

And therein lies the rub... how do you know that the info needs to be changed unless you know that something changed in the DB? (Rhetorical - you need to answer that for yourself, not for me...) The old programmer's rule says that Access never tells you anything you didn't tell it first.

They can only open the word document via the file path in the database, it's not available to them to open via Word.

After the first time they open it via Word on their machine, the path is available to them via the Word (or Windows) "recently opened files" list unless you actively avoid making an entry to that list, and such behavior is not the default for Word or Windows. Don't assume the users can't get there from here.

OK, as to bookmarks - I believe that Booksmarks is a collection of Word items like Paragraphs and Words and Tables and Figures. Which means you can open the Bookmarks collection to look at individual bookmarks. Look up Booksmarks in Word's VBA help to see what the VBA interface would have to do from Word to manipulate a bookmark in a Word Macro. When you have a Word document open via Automation from Access, you would do the same thing except have Access "push the buttons" for you.
 
I suppose I have to assume that every time they open the word document the bookmarks need updating, so every time they open the word document they would refresh regardless of if there's been a change or not.

I really want to produce this report via Access but because the user needs to insert a large interpretation into the document this isn't possible/not what they want.

You're right about them opening the document via Word of course but they are, however, used to creating and accessing these reports via an external source and also if they do open the Word document via word they would only amend the interpretation.
 
I'm getting no where fast with this - can anybody help me to update existing bookmarks with new text via Access opening the saved word document?

Desperate!

DBL
 
This is what I've got so far but it's tagging the revised data on the end, not overwriting the existing data:

Function FindBMark()
Dim WordObj As Word.Application
Dim WordDoc As Word.Document
Dim WordRange As Word.Range
Dim filepath As String

filepath = Forms!FrmCase!sfrmReportLog![RLlink]

Set WordObj = CreateObject("Word.Application")
Set WordDoc = WordObj.Documents.Open(filepath)
WordObj.Visible = True


Set WordRange = WordDoc.Goto(What:=wdGoToBookmark, Name:="Mortuary")
WordRange.InsertAfter "Forms!frmCase!sfrmPostMortem![PMPort]"

Set WordObj = Nothing
End Function
 

Users who are viewing this thread

Back
Top Bottom