ADO with Word XP and VBA

L

Lola

Hello everybody:

I have been working in Access XP with ADO and VBA. It's simple, using
the ADODB object all the work is done. I'm trying to do the same with
VBA in Word XP, but I'm in trouble, because there's no ADODB object in
Word XP. VBA says to me that "User defined type doesn't defined"
(translated from Spanish) in the line that says "Dim Cnx As
ADODB.Connection".

I think I can use ADO with Word (Access can, why can't Word?), and
maybe that's the mistake.

Question is, if I can use ADODB with Word and VBA, which is/are the
object/s that I must use? Of course, I'm looking in the Help of VBA,
but I haven't found something (Maybe I'm blind :-? ).

Thanks anyway.
 
L

Lars-Eric Gisslén

Lola,

You should add a reference to one of the 'Microsoft ActiveX Data x.x Objects
Library' in your VBA project, or use CreateObject like below if you want
version independent code:

oConnection = CreateObject("ADODB.Connection")

OLEDB is not an Office product but something that will replace ODBC is the
future

Regards,
Lars-Eric
 
L

Lola Cardenas

Lars,
You should add a reference to one of the 'Microsoft ActiveX Data x.x Objects
Library' in your VBA project, or use CreateObject like below if you want
version independent code:
oConnection = CreateObject("ADODB.Connection")

I have tried this (CreateObject) and it seems to work. But I'm
interested in knowing how can I add a reference to the "Microsoft
ActiveX Data x.x Objects Library" in my VBA project. I have been
searching for options in the VBA Editor, but I haven't found *the*
option.

Thanks a lot :)

Lola.
 
L

Lars-Eric Gisslén

Lola,

When in the VBA editor, select Tools in the menu and Referenses in the
dropdown menu. Find 'Microsoft ActiveX ...' in the list of available COM
componentes. Make sure you check the checkbox beside the version you want to
use. On this machine I have 5 versions, 2.0 - 2.7

Regards,
Lars-Eric
 

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