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

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Pass Word Bookmark Values To Access 2007    
 
   
River34
post Feb 7 2012, 11:33 AM
Post #1

UtterAccess Addict
Posts: 252
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

objWord.Quit
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.
Thanks!
Go to the top of the page
 
+
River34
post Feb 7 2012, 11:45 AM
Post #2

UtterAccess Addict
Posts: 252
From: Metro Detroit



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

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 20th December 2014 - 07:13 AM