[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

word 2007 vba adodb.connection error

Posted on 2009-02-23
1
Medium Priority
?
294 Views
Last Modified: 2012-06-27
Hello experts,

I have a word 2007 document which contains vba code that is executed when the document is opened. The vba code sets up a connection to a db and reads out some values.
Now I get an error in the line:
Dim cnArthro As ADODB.Connection

The error says:
"Compile error. User defined type not defined"

And this is weird because I have other word documents which contain the exact same codepart - and they work.

Does anybody have a clue what the problem is here?

Thanks a lot for your help
Private Sub Document_Open()
 
Dim nFileNum As Integer, sID As String
nFileNum = FreeFile
 
 
'------------------------Pfadname HIER ändern---------------------------
Open "\\my_server\Docs\temp.txt" For Input As nFileNum
'Auslesen der ID aus dem Textfile
Line Input #nFileNum, ID
'Auslesen des gewünschten Drucks aus dem Textfile
Line Input #nFileNum, Druck
'Variable für die ID
Dim KundeID As Integer
KundeID = CInt(ID)
'Variable für den gewünschten Ausdruck
Dim DruckID As Integer
DruckID = CInt(Druck)
 
' Create a connection object.
Dim cnArthro As ADODB.Connection
Set cnArthro = New ADODB.Connection
 
' Provide the connection string.
Dim strConn As String

Open in new window

0
Comment
Question by:arthrex
1 Comment
 
LVL 4

Accepted Solution

by:
davidsperling earned 2000 total points
ID: 23711049
Have you selected Microsoft ActiveX Data Objects 2.x in Tools->References (in vba editor) ?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …
Suggested Courses
Course of the Month19 days, 3 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question