Link to home
Start Free TrialLog in
Avatar of arthrex
arthrexFlag for Germany

asked on

word 2007 vba adodb.connection error

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

ASKER CERTIFIED SOLUTION
Avatar of davidsperling
davidsperling

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial