Dave,
I am using Office 2002. I created a test doc at "C:\My Documents\Wordt est.
doc" and basically copied and pasted the code from the web you recommented
into a Access test database:
---------
Sub FindBMark()
Dim wordApp As Word.Applicatio n
Dim wordDoc As Word.Document
Dim wordRange As Word.Range
Set wordApp = CreateObject("W ord.Application ")
Set wordDoc = wordApp.Documen ts.Open("C:\My Documents\Wordt est.doc")
wordApp.Visible = True
' go to the bookmark named "City."
Set wordRange = wordDoc.Goto(Wh at:=wdGoToBookm ark, Name:="City")
wordRange.Inser tAfter "Los Angeles"
' print the document.
wordDoc.PrintOu t Background:=Fal se
' save the modified document.
wordDoc.Save
' quit Word without saving changes to the document.
wordApp.Quit SaveChanges:=wd DoNotSaveChange s
Set wordApp = Nothing
End Sub
--------------
But it didn't work. I don't know if it is related to Office version. There
are maily 2 types of errors when I run the above code:
1. It doesn't recognized this declaration:
Dim wordApp As Word.Applicatio n
2. In some of the lines, it error message is "Object doesn't support this
property or method"
Any help will be appreciated.
Richard
Dave G @ K2 wrote:
>You could use so-called Automation. Microsoft's help file tells you
more or less everything you need to know. Here's the Office 2000 one
http://support.microsoft.com/kb/260410 but there are others for
different versions. I started using this technique in Access 97. I'm
now on 2003 and it still works perfectly without the need to make any
changes.
The basic idea is to store the documents as templates, and those
templates contain named bookmarks. The VBA code opens the template as a
new document and inserts the required data at the relevant bookmarks.
It works perfectly for me and is pretty easy to get your head round
Dave
--
Message posted via
http://www.accessmonster.com