Dim sht As Excel.Worksheet
Dim wkb As Excel.Workbook
Dim rng As Excel.Range
Dim strTable As String
Dim strRange As String
Dim strSaveName As String
Dim strPrompt As String
Dim strTitle As String
Dim strDefault As StringOn Error GoTo ErrorHandlerRe-create table for export:strTable = “tmakAccountSummary”
DoCmd.SetWarnings False
DoCmd.OpenQuery “qmakAccountSummary”Create worksheet save name:strWorksheetPath = GetWorksheetsPath()
strWorksheet = “Account Summary”
strSaveName = strWorksheetPath & strWorksheet & “.xls”
Debug.Print “Worksheet save name” & strSaveNameOn Error Resume NextDelete existing worksheet (if there is one):Kill strSaveNameOn Error GoTo ErrorHandlerExport query data to a new worksheet in Excel 9 format:DoCmd.TransferSpreadsheet transfertype:=acExport, _
spreadsheettype:=acSpreadsheetTypeExcel9, _
TableName:=strTable, FileName:=strSaveName, _
hasfieldnames:=TrueOpen the newly created worksheet and insert title material:Set appExcel = GetObject(, “Excel.Application”)
appExcel.Workbooks.Open (strSaveName)
Set wkb = appExcel.ActiveWorkbook
Set sht = appExcel.ActiveSheet
sht.ActivateWith shtPart II Writing VBA Code to Exchange Data between Office Components