0

I want to import data into MS excel 2010 from SQL developer (Oracle) using VBA macro

I am using below code but not able to connect to SQL devevloper. Getting error like Provider not found or not installed.

Kindly help.

Sub ImportData()

Sheets("sheet1").Select

With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
    "OLEDB;Provider=MSDAORA.1;User ID=MY_USER;password= MY_PW;Data Source=sourceName", Destination _
    :=Range("$A$1")).QueryTable
    .CommandType = xlCmdSql
    .CommandText = "Select Main.[ID],Main.[Count1] From Main Where Main.[Count1] > 25"
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .PreserveColumnInfo = True
    .Refresh BackgroundQuery:=False
End With

End Sub
5
  • 1
    You need to have the Oracle client installed. Feb 10, 2016 at 5:32
  • Thanks for above comment..On my machine SQL developer is installed to access Oracle database... Feb 10, 2016 at 14:27
  • Oracle_11G_Client_R2 is installed on my machine Feb 10, 2016 at 14:45
  • Do you have that specific driver installed? Feb 10, 2016 at 15:34
  • Could you please let me know the driver name Feb 11, 2016 at 6:27

1 Answer 1

0

Can you confirm you can tnsping the database from your machine?

If so can you confirm you can connect to the database and run that query from sqlplus?

It looks like sqlserver syntax? I'm not entirely sure it would run in Oracle, I may be wrong it might well.

If all is ok, can you confirm whether you are running 32/64bit oracle? MSDAORA would probably need to match.

Assuming all above is correct then these links might help.

http://blog.mclaughlinsoftware.com/microsoft-excel/how-to-query-oracle-from-excel-2007/

https://support.office.com/en-us/article/Connect-to-an-Oracle-database-Power-Query-d7fbd231-a705-4eb7-83b3-a66bfb678395

1
  • I can't add comments on your post so had to add this as an answer, the links should help though
    – DJ811
    Feb 11, 2016 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.