Good Evening,
I have the foillowing Script in MS Access, which calls Excel 2003.
Can anyone tell me how to call Excel 2007, instead of Excel 2003 ?
Public Sub ActVsPlanPrj()
' 1-Set the recordset in pivot table format (DoCmd.OpenQuery ("Qry_ActualVsPlan"), acViewPivotTable)
' 2-export it to Excel
' 3-Copy pivot table content
' 4-open the template spreadsheet
' 5-paste the clipboard to the template
' 6-replace the right most column (grand total) with variace formula (Actual todate-plan todate)
' 7-run the existing macro for formatting
' 8-Update the reporting dates
' 9-Close the pivot table
Dim RowNum As Integer
' 1- open the query in pivot table format******************************************
DoCmd.OpenQuery ("Qry_ActualVsPlan"), acViewPivotTable
' 2-export it to Excel*************************************************************
Set ExcelApp = CreateObject("Excel.Application")
DoCmd.RunCommand acCmdPivotTableExportToExcel
' 3-Copy pivot table content*******************************************************
RowNum = 4
On Error Resume Next 'this is a very important line
Do While ExcelApp.Cells(RowNum, "G").Value <> ""
RowNum = RowNum + 1
Loop
ExcelApp.Range("A4:G" & RowNum).Select
ExcelApp.Selection.Copy
' 4-open the template spreadsheet*************************************************
ExcelApp.Workbooks.Open "xxxxxx" connection\Actual vs Plan Template.xlsm"
ExcelApp.Sheets("By Project").Select
' 5-paste the clipboard to the template
ExcelApp.Range("B2").Select
ExcelApp.ActiveSheet.Paste
ExcelApp.ActiveWindow.ActivateNext
ExcelApp.DisplayAlerts = False
ExcelApp.ActiveWindow.Close (False)
ExcelApp.DisplayAlerts = True
ExcelApp.Windows("Actual vs Plan Template.xlsm").Activate
Regards,
Bob
I have the foillowing Script in MS Access, which calls Excel 2003.
Can anyone tell me how to call Excel 2007, instead of Excel 2003 ?
Public Sub ActVsPlanPrj()
' 1-Set the recordset in pivot table format (DoCmd.OpenQuery ("Qry_ActualVsPlan"), acViewPivotTable)
' 2-export it to Excel
' 3-Copy pivot table content
' 4-open the template spreadsheet
' 5-paste the clipboard to the template
' 6-replace the right most column (grand total) with variace formula (Actual todate-plan todate)
' 7-run the existing macro for formatting
' 8-Update the reporting dates
' 9-Close the pivot table
Dim RowNum As Integer
' 1- open the query in pivot table format******************************************
DoCmd.OpenQuery ("Qry_ActualVsPlan"), acViewPivotTable
' 2-export it to Excel*************************************************************
Set ExcelApp = CreateObject("Excel.Application")
DoCmd.RunCommand acCmdPivotTableExportToExcel
' 3-Copy pivot table content*******************************************************
RowNum = 4
On Error Resume Next 'this is a very important line
Do While ExcelApp.Cells(RowNum, "G").Value <> ""
RowNum = RowNum + 1
Loop
ExcelApp.Range("A4:G" & RowNum).Select
ExcelApp.Selection.Copy
' 4-open the template spreadsheet*************************************************
ExcelApp.Workbooks.Open "xxxxxx" connection\Actual vs Plan Template.xlsm"
ExcelApp.Sheets("By Project").Select
' 5-paste the clipboard to the template
ExcelApp.Range("B2").Select
ExcelApp.ActiveSheet.Paste
ExcelApp.ActiveWindow.ActivateNext
ExcelApp.DisplayAlerts = False
ExcelApp.ActiveWindow.Close (False)
ExcelApp.DisplayAlerts = True
ExcelApp.Windows("Actual vs Plan Template.xlsm").Activate
Regards,
Bob