X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Pass Word Bookmark Values To Access 2007    
post Feb 7 2012, 11:33 AM

Posts: 252
Joined: 12-May 10
From: Metro Detroit

I can pass an Access variable to a Word bookmark easily.
im objWord As Word.Application
Dim doc As Word.Document
With objWord
.Visible = True
Set doc = .Documents.Add("MyDocName.dot")
With doc.Bookmarks
.Item("bmkName").Range.Text = strName
.Item("bmkAddress").Range.Text = strAddress
.Item("bmkCityLine").Range.Text = strCityLine
End With
Now, I need to retrieve data from Word bookmarks into Access. I found a site with the following posted that shows Access reading two bookmarks:
Dim objWord As Word.Application
Dim objDoc As Word.Document
Dim objRange As Word.Bookmark
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("c:\scripts\word\bookmarkdoc.doc")
Set objRange = objDoc.Bookmarks("NameBookmark").Range

Wscript.Echo objRange.Text

Set objRange = objDoc.Bookmarks("AddressBookmark").Range
Wscript.Echo objRange.Text

This will not run for me. I cannot compile because it gives a 'Type Mismatch' error at the objRange.Text line (Wscript.Echo objRange.Text) which is understandable since the objRange is Dim as a bookmark.range (Set objRange = objDoc.Bookmarks("NameBookmark").Range).
I have been working on this for 2 hrs. now and I'm really getting frustrated. I've tried to create this function a half dozen ways and they all fail. I know that there has to be as simple solution to this.
I am using Access 2007 and have References set for Microsoft Word 12.0 Object Library and (since it was started in Access 3002) Microsoft DAO 3.6 Library. If anyone can tell me what I'm doing wrong, the help will truly be appreciated.
Go to the top of the page
post Feb 7 2012, 11:45 AM

Posts: 252
Joined: 12-May 10
From: Metro Detroit

I forgot to add that I am working with a Word 97-2003 doc.
Go to the top of the page

Custom Search
RSSSearch   Top   Lo-Fi    24th April 2018 - 11:36 AM