Embedding data from a SQL server

M

Mr. Smith

Hi All,

I'm quite familar with working with data from various databases in Office
apps but never Powerpoint. I tried the following code to test the workings
of using SQL data in a PP pres but it fails. Can anyone tell me why? Am I
missing a reference? I don't think I am but maybe on of you MS gurus can help
me.

(Taken directly from Office help)
********************************

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

*********************************

Specifically it fails on:

"Set appOffice = Application.OfficeDataSourceObject"

reporting that "Method or data member not found." for
"OfficeDataSourceObject" so how can I make OfficeDataSourceObject a member of
the Powerpoint Application object? A decent google search has offered me
nothig that I have been able to make sense of.


Cheers,
Mr. Smith
 
M

Mr. Smith

Steve Rindsberg said:
If you can find a working example of this code in another application, find out
what references have been set in the project.

The PowerPoint application doesn't have an OfficeDataSourceObject .... er ...
object.

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


Stupid OfficeDataSourceObject doesn't work at all.

If anyone cares, Here's how to do it, just make sure you include "Microsoft
ActievX Data Objects 2.x" reference in you workbook, PPT or Document

--------------------------------

Sub tester()

Dim rst As New ADODB.Recordset
Dim cnn As ADODB.Connection

Set cnn = New ADODB.Connection
cnn.ConnectionString = "Provider=Microsoft.Access.OLEDB.10.0;Persist
Security Info=True;Data Source=10.15.1.66\Refresh;User
ID=UserName;Password=Passowrd;Initial Catalog=DatabaseName;Data
Provider=SQLOLEDB.1"
cnn.Open

rst.Open "tblName", cnn

rst.Close
cnn.Close

End Sub

----------------------------------

Seriously, I think its about time I became an MVP :S


Mr.Smith
 

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