View Single Post
Old 09-03-2018, 04:49 PM   #19
Newly Registered User
Join Date: Dec 2012
Posts: 39
Thanks: 12
Thanked 0 Times in 0 Posts
gippsy is on a distinguished road
Re: Export query from ms access to excel and create chart

June7, Cronk, JHB, Ranman256
For all of you, many thanks.
Finally, I have a code to export and create a chart in excel.
This is my code:
ub cmdTransfer_Click()
Dim sExcelWB As String
Dim xl As Object ''Excel.Application
Dim wb As Object ''Excel.Workbook
Dim ws As Object ''Excel.Worksheet
Dim ch As Object ''Excel.Chart
Dim myMax As Double
Dim myMin As Double

Set xl = CreateObject("excel.application")
sExcelWB = "D:\testing2\" & qry_01.xls" ''sometimesthe i write "qry_task"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry_task", sExcelWB, True
Set wb = xl.Workbooks.Open(sExcelWB)
Set ws = wb.Sheets("qry_task")

Set ch = ws.Shapes.AddChart.Chart
gippsy is offline   Reply With Quote