Access - Word document (1 Viewer)

kirsty

Registered User.
Local time
Today, 10:20
Joined
Nov 5, 1999
Messages
19
Hi,

I have created a command button on a form which when clicked, opens a word document and inserts relevant text from the current record into bookmarks in the word document.

I am trying to write some code which ensures that the word document is saved as one of the field names on my record.

The type of code I have been using, for example is:-

objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges. (Instead of the DoNotSaveChanges part I would like to force the word document to save as a field on the current record).

Anyone have any ideas?

many thanks in advance,
Kirsty.
 

bauer

Registered User.
Local time
Today, 06:20
Joined
Aug 23, 2001
Messages
77
I got this from the Wrox book, VBA 97:

Dim objWord As Word.Application
Dim objDoc As Object

Set objWord = New Word.Application
objWord.Visible = True
Set objDoc = objWord.Documents.Add(filename)

'Code to put in the record at the bookmark

objDoc.SaveAs "filenameroot" & recDonor("LastName")
'where fileNameRoot is the root C:/ etc, and file name, and recDonor("LastName") is a a field that I appended to the file name

objDoc.Close
objWord.Quit

Hope that this helps

Bauer
 

odun

Registered User.
Local time
Today, 03:20
Joined
Apr 24, 2005
Messages
108
Hi, can you highlight the steps you used to open the word document and insert relevent texts from your form into the word document, that's exactly what I need to do, please help.
kirsty said:
Hi,

I have created a command button on a form which when clicked, opens a word document and inserts relevant text from the current record into bookmarks in the word document.

I am trying to write some code which ensures that the word document is saved as one of the field names on my record.

The type of code I have been using, for example is:-

objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges. (Instead of the DoNotSaveChanges part I would like to force the word document to save as a field on the current record).

Anyone have any ideas?

many thanks in advance,
Kirsty.
 

Users who are viewing this thread

Top Bottom