merge from excel to word variable name

M

Mike Molyneaux

I'm running Excel & Word 2000 on nt4, sp6

I'm trying to create a mailmerge file from Excel with data
from the excel sheet.

I get a 'variable not defined' compiler error on
the 'wdMailingLabels' value of
the '.ActiveDocument.MailMerge.MainDocumentType = ' line.

I expect similar compile errors on other values. How can I
find what I need to code these in order to execute the
macro?


Dim wordApp As Object
Set wordApp = CreateObject("Word.Application")

With wordApp

.ActiveDocument.MailMerge.MainDocumentType =
wdMailingLabels

End With

wordApp.Quit
Set wordApp = Nothing


thanks for any help
 
J

Jezebel

If you want VBA to know what wdMailing Labels means, you have to add to your
project the library that defines it -- in this case Word. Go to Tools >
References and select 'Microsoft Word 9.0 Object Library' from the list.
 
J

JGM

Hi Mike,

I am not sure, but try

.ActiveDocument.MailMerge.MainDocumentType =
WordApp.wdMailingLabels

I think I once solve a problem in a similar situation this way, but my
memory may be playing tricks on me!

Cheers!
 

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