Data sources

M

Mr. Smith

Nothing ticks me off more than when you copy a complete sub/function
straight out of an office VBA help example and it doesn't work. Grrrrr!!!!

Try this:

******************
Sub SetAndReturnDataSourceName()
Dim appOffice As Office.OfficeDataSourceObject

Set appOffice = Application.OfficeDataSourceObject

With appOffice
.Open bstrConnect:="DRIVER=SQL Server;SERVER=10.15.1.66\Refresh;" & _
"AdlerM=user;PWD=Eagle1234;DATABASE=Refresh",
bstrTable:="Employees"

If .DataSource = "" Then
.DataSource = "Refresh"
MsgBox .DataSource
End If
End With
End Sub
*****************************

I've tried it in PPT, Excel, and Word. They all fail on:

** Set appOffice = Application.OfficeDataSourceObject **

Reporting "Object does not supprt this method or property."

Fine. So what reference do I need to include? Come on MVP's!!


Mr. Smith
 
M

Mouckster

I've come across the same problem when trying to connect to a database.
The reference you need is:

Microsoft ActiveX Data Objects 2.1 Library

Dan.
 

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