Version conflict with Word

M

Morten Snedker

Some code was used internally in our organisation, so early binding
was used when mail merging with Word.

Now it is to be used externally. We use Word 10 and some external
users 9.0. So I would change the code to use late binding - and then
my problem occurs:


Dim objWordDoc As Object
Set objWordDoc = CreateObject("Word.Document")

Set objWordDoc = objWord.Documents.Add(strSkabelon, , , False)
If Len(strSaveFile) > 0 Then objWordDoc.SaveAs strSaveFile

With objWordDoc.MailMerge
.MainDocumentType = wdFormLetters

The two last lines will fail on a compile, since wdFormLetters is
unknown. But how do I solve it properly? How do I reference to these
Word properties along with late binding?


Any help is greatly appreciated.


/Snedker
 
B

Brendan Reynolds

You'll need to use the numeric values of the constants. Rather than
scattering those numbers throughout your code, though, define your own
public constants and use those in place of Word's intrinsic constants. For
example, in a standard module ...

Public Const glngcWordFormLetters As Long = 0

Then use it like so ...

With objWordDoc.MailMerge
.MainDocumentType = glngcWordFormLetters

You can find the numeric values of the constants by adding the reference to
an MDB and then either printing the values in the Immediate window (?
wdFormLetters) or looking them up in the Object Browser.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 

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