Log in

View Full Version : [SOLVED:] Export to Excel Macro?



bobdole22
09-03-2013, 07:35 AM
I've read that their are ways to export a report from access -> excel without overwriting the file completely. Is this true? All the tutorials I've looked up have said nothing about it, and it always leaves me overwriting the file.

I need it to be exported to say, Sheet 2 of a given excel file, for example? Is that even possible?

I'm also trying to do this in a Macro as part of my automation process and I'm using office 2007.

mrojas
09-10-2013, 05:18 PM
How about posting solution for the benefit of all?

bobdole22
09-12-2013, 06:56 AM
Went in a different direction. Used a link code here to run macros instead of a report:


With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" & dbFile & ";Mode=Share Deny Write;" _
, _
"Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Pas" _
, _
"sword="""";Jet OLEDB:Engine Type=6;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Tra" _
, _
"nsactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB" _
, _
":Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex" _
, " Data=False"), Destination:=Range("$B$15")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("qry_Report1")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = _
dbFile
.ListObject.DisplayName = tableText
.Refresh BackgroundQuery:=False
End With