Opening a word document

  • Thread starter Thread starter Meryl
  • Start date Start date
M

Meryl

I have a donations form. There is a control button to
open Word to generate a thank you note, populating the
letter with name, date and donations amount. At work,
the code on the button works correctly no matter how many
time I click on it, however, on my home computer I get an
error if I use the button a second time when it tries to
load the document. It will only work again if I reboot
the computer. The error reads: "Method 'Add' of
objects 'Document' failed". At work, I have Access 2000
and Word 2000. At home, I have Access 2000 and Word 2002.

Code is below:
Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

Dim curAmount As Currency
curAmount = Forms![Donor-Registration Form-US]!
[individual donations subform]!Amount

' Open Microsoft Word using automation

oApp.Documents.Add "C:\Documents and
Settings\Meryl\Application
Data\Microsoft\Templates\RegDonationLetter.dot"
oApp.Visible = True

Thanks for your help!
..
 
I don't have Word VBA Help here to check, but doesn't Documents.Add create a
new, unsaved empty document? If so, what is the filename doing on that
statement? Don't you mean .Open? Maybe the two versions of Word treat this
differently?

HTH,
TC
 
Back
Top