How to connect to database through Macro Excel in MAC

Jibanendu

New Member
Joined
Apr 20, 2011
Messages
16
Hi All,

Im a beginner in Macro Excel. I have been trying to connect database through Macros. But I am getting the "error error 424 object required". Iam using MAC.

Below is the mentioned code that i have been working on.

/***** Start of code******?
Sub AnalyzeDBA1Tables()
Dim str As String
Dim strSQL As String

Set cnn = CreateObject(“ADODB.Connection”)

cnn.Open ("User ID=scott" & ";Password=tiger" & ";Data Source=**.**.**.**" & ";Provider=*")

Set rs = CreateObject(“ADODB.Recordset”)

row = 5

col = 5

numRs = rs.Fields.Count

num = 0

strSQL = "select * from employee"

rs.Open strSQL, cnn

Do Until rs.EOF

Do While num < numRs

Cells(row, col + num).Value = rs(num)

num = num + 1

Loop

num = 0

row = row + 1

rs.moveNext

Loop

rs.Close

cnn.Close

End Sub

/*****End of code********/

Please guide me through how to establish the connection.

Your valuable help is required urgently.

Thanx in advance,
Jibanendu
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
sorry about the error I tried to run the code again I faced this error "Run Time Error:429" ActiveX Componenet can't create object

Please help me out, I am in serious need of your help.

Thanx in advance,
Jibanendu
 
Upvote 0
HI,

Anyone could please help me out with the problem. I am in serious need . Please help me out.

Thanx in advance
Jibanendu
 
Upvote 0
Please don't bump your posts every 10 minutes.

You can't use ADO on a Mac.
 
Upvote 0
Hi Rory,
Thanks for your advice.
Can you please advise me what I need to use then, rather can you suggest me how to establish a database connection through VB Macros in Excel.
I am using MS-Excel 2011.

Please help me out.

Thanx in advance,
Jibanendu
 
Upvote 0
I don't know as I don't use Macs for work. I suspect you need DDE though.
 
Upvote 0
Hi ,

Thanx for your help Rory.But I am not so sure how this DDE will work in MAC system.

Can anyone please suggest me more on this.

Thanx in advance,
Jibanendu
 
Upvote 0
HI,

Please help me out. I am in serious issue,as I am using MAC to connect database through Macro Excel. Even I tried a sample code i.e

/***** Start of code*****/

Public objSession As Object
Public objDataBase As Object
Sub ConnectToOracle1()
Dim strSQL As String
Dim strResult As String
Dim strCount As String
Dim OraDynaSet As Object

'Create a reference to the OO4O dll
Set objSession = CreateObject("OracleInProcServer.XOraSession")
'Create a reference to my database
Set objDataBase = objSession.OpenDatabase("MyOraDB", "scott/tiger", 0&)
strSQL = "select count(*) from emp"

'Retrieve the results from Oracle
Set OraDynaSet = objDataBase.DBCreateDynaset(strSQL, 0&)

'Convert the result to String
strCount = CStr(OraDynaSet.Fields(0).Value)

'Prepare the message
strResult = "There are " & strCount & " employees in emp."

'Show the message
MsgBox strResult

End Sub
/****** end of code******/

It also shows the same error message "Run Time Error:429 ActiveX Componenet can't create object".

Please guide me through this. Your views would be truly helpful for me.

Thanx in advance,
Jibanendu
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top