DOCVARIABLE not being set

B

Bill Agee

I have a Word document that contains the following:

Date

{ DOCVARIABLE "AttyFirm" }

Dear Mr. Lewis:

etc

and an Access program that contains the following code:

Private Sub cmdDocVariable_Click()
Dim wAttyFirm As String
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
wAttyFirm = "Smith, Jones and Johnson"
Set WordApp = New Word.Application
Set WordDoc = New Word.Document
Set WordDoc = WordApp.Documents.Add("C:\Documents and
Settings\Administrator\Application
Data\Microsoft\Templates\DTVLettertest.dot")
WordDoc.Variables("AttyFirm").Value = [wAttyFirm]
WordDoc.Fields.Update
WordApp.Visible = True
Debug.Print wAttyFirm ' Smith, Jones and Johnson
WordDoc.SaveAs filename ' where filename is a path and filename
End Sub

Absolutely nothing happens. Is there something obvious that is wrong?
 
D

Doug Robbins - Word MVP

Hi Bill,

Why do you have the square brackets around [wAttyFirm] in the command

WordDoc.Variables("AttyFirm").Value = [wAttyFirm]

?

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top