Read data from a table in .MDB file into Excel 2013 with VBA -
i'm trying import data access .mdb file excel 2013 spreadsheet.
so far, i've tried converting database 2007 format hasn't worked (2 methods i've tried far)
is there simpler way of importing data straight table in .mdb file sheet in excel 2013 spreadsheet? (end result)
sub convertaccessdb() application.convertaccessproject _ sourcefilename:="c:\new\pabxcalls.mdb", _ destinationfilename:="c:\my documents\pabxcalls2007.accdb", _ destinationfileformat:=acfileformataccess2007 end sub ' **** gives runtime error 438 - object doesn't support property or method ***
and
sub command7_click() dim app new access.application app.visible = true app.automationsecurity = msoautomationsecuritylow app.syscmd 603, "c:\new\pabxcalls.mdb", "c:\new\pabxcalls_new.mdb" set app = nothing end sub ' *** runs, not output file required ***
thanks guys!!!
found out didn't have convert database. pull data using query , adodb connection, follows.
thanks anyway!
sub getcalldata() dim objadocon object dim objrcdset object dim dailyoutgoing, dailyincoming, monthlyoutgoing, monthlyincoming string dailyoutgoing = "select calls.extension,sum(calls.duration) calls (((calls.calldate)=date())) , (((calls.calltype)=""o"")) group calls.extension, calls.calldate ;" dailyincoming = "select calls.extension,sum(calls.duration) calls (((calls.calldate)=date())) , (((calls.calltype)=""i"")) group calls.extension, calls.calldate ;" set objadocon = createobject("adodb.connection") set objrcdset = createobject("adodb.recordset") objadocon.open "provider = microsoft.jet.oledb.4.0;data source = \\remotehost\pabxsoft\call collector\data\pabxcalls.mdb" ' *** daily outgoing *** thisworkbook.worksheets("call_data").range("a3:b24").value = "" objrcdset.open dailyoutgoing, objadocon thisworkbook.worksheets("call_data").range("a3").copyfromrecordset objrcdset set objrcdset = nothing ' *** daily incoming *** set objrcdset = createobject("adodb.recordset") thisworkbook.worksheets("call_data").range("a27:b46").value = "" objrcdset.open dailyincoming, objadocon thisworkbook.worksheets("call_data").range("a27").copyfromrecordset objrcdset set objadocon = nothing set objrcdset = nothing end sub
Comments
Post a Comment