Hi John,
Thanks for your answer .... I understand what you mean ...
so I replaced
Dim wrd As Word.Application with
Dim wrd As Object
I refer to my 'wrd' in several functions
template = CurrentProject.Path & "\invoice.dot"
Set wrd = New Word.Application
Set DC = wrd.Documents.Add(template)
How - after it is an Object now - can I refer to word
??
Gina
John Nurick said:
Hi Gina,
This is a fairly frequent problem. If you need your program to work
reliably across multiple versions of Office, it's usually best to use
late binding for all the OLE Automation. What you have now - references
and Dim wrd As Word.Application - is early binding. For late binding,
remove the reference to the Word and Excel object libraries, replace
Dim wrd As Word.Application
with
Dim wrd As Object 'Word.Application
and so on, and also replace all Word and Excel constants (e.g.
wdLineSpaceDouble) with the equivalent values (e.g. 2).
I always use early binding when programming, because Intellisense, the
Object Browser and the compiler all help avoid and detect errors. But
once the code is working I often modify it to use late binding to make
it more reliably portable between systems.