How to make Excel recognize ".accbd" files?

rugbier

New Member
Joined
Jun 14, 2012
Messages
3
Greetings!

Well this is my first post and I'm not a native speaker, so if asomething isn't clear enough, just ask me...

I have a code in Excel to export data from Access, but apparently it doesn't recognize ".accbd" as a valid extension for an Access file.

The code is:

Code:
Sub ExtraiVarias()


Dim Conex As ADODB.Connection
Dim RS As ADODB.Recordset
Dim Diretorio As String
Dim Col As Integer
Dim Lin As Integer
Dim sSQL As String
Dim COD_BD As Integer
Dim DataInicial As Date


Range("A11:z1200").ClearContents


DataInicial = Range("B5").Value
DataFinal = Range("B6").Value


Range("A11").Value = DataInicial


Lin = 11


While Cells(Lin, 1).Value <> DataFinal


    Cells(Lin + 1, 1).FormulaR1C1 = "=EDATE(R[-1]C,1)"
    
    Lin = Lin + 1
    
Wend


Diretorio = "V:\BD_MACRO_teste.accdb"


Col = 2


Set Conex = New ADODB.Connection


With Conex


    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .Open Diretorio
    
End With


While Not IsEmpty(Cells(8, Col))


COD_BD = Cells(8, Col).Value


 Set RS = New ADODB.Recordset
 RS.CursorLocation = adUseServer




sSQL = "SELECT  VALOR"
sSQL = sSQL & " FROM DADOS"
sSQL = sSQL & " WHERE COD_BD=" & COD_BD & "And Data >= #" & DataInicial & "#" & "And Data <= #" & DataFinal & "#" & ";"




RS.Open Source:=sSQL, ActiveConnection:=Conex, CursorType:=adOpenStatic, _
     LockType:=adLockReadOnly
            


Cells(11, Col).CopyFromRecordset RS


RS.Close


Col = Col + 1


Wend


Conex.Close
            
End Sub

The error message is: "Unrecognized database format 'V:\BD_MACRO_teste.accdb'", and appears in the line ".Open Diretorio".

I presume that I need to locate the necessary reference in the library tha allows me to use this kind of files, because it works when i save the same database as an Access 2003 file (".mdb"), but i don't know how to find it. Any new idea will be really helpful.

Thanks in advance,
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Upvote 0
Thanks for the answer!

Unfortunately, as I am using VBA, this probably won't work. Besides, I'm using ADO, and Microsoft DAO 3.6 object library is already not selected. I probably need to find the correct library in my PC, but I can't figure out which one.

Does anyone have another suggestion?

Thanks in Advance!
 
Upvote 0
Found the answer here!


New engine (ACE), try "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=MyDatabaseName.accdb;"


So, i just nedd to change the Provider of the ADODB Connection


Well, thanks anyway! Hope it's useful!
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

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