Hi sorry to post again, but you are all very helpful and ive almost finished by DB.
I have a button that has to export 4 queries into excel spreadsheets, and then open an excel spreadsheet that has links to the 4 exports and does some nuber crunching and produces a report.
the button code is:
Dim fullpath As String
fullpath = CurrentProject.Path
' exports expenditure
DoCmd.OutputTo acQuery, "qryExpenditureExport", "MicrosoftExcelBiff8(*.xls)", fullpath & "\Exp.xls", True, "", 0
' exports income
DoCmd.OutputTo acQuery, "qryIncomeExport", "MicrosoftExcelBiff8(*.xls)", fullpath & "\In.xls", True, "", 0
' exports priority debts
DoCmd.OutputTo acQuery, "qryPriorityDebtsExport", "MicrosoftExcelBiff8(*.xls)", fullpath & "\PRIO.xls", True, "", 0
' exports non priority debts
DoCmd.OutputTo acQuery, "qryNPDExport", "MicrosoftExcelBiff8(*.xls)", fullpath & "\NPD.xls", True, "", 0
' Access form button
Call OpenSpecific_xlFile
It calls this code to open the file:
Sub OpenSpecific_xlFile()
' Late Binding (Needs no reference set)
Dim oXL As Object
Dim oExcel As Object
Dim sfullpath As String
Dim sPath As String
' Create a new Excel instance
Set oXL = CreateObject("Excel.Application")
' Only XL 97 supports UserControl Property
On Error Resume Next
oXL.UserControl = True
On Error GoTo 0
' Full path of excel file to open
On Error GoTo ErrHandle
sfullpath = CurrentProject.Path & "\FinancialStatementTemplate.xlt"
' Open it
With oXL
.Visible = True
.Workbooks.Open (sfullpath)
End With
ErrExit:
Set oXL = Nothing
Exit Sub
ErrHandle:
oXL.Visible = False
MsgBox Err.Description
GoTo ErrExit
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Run it from a form button
Private Sub cmdOpenExcelFIle_Click()
' Access form button
Call OpenSpecific_xlFile
I need to then make sure that FinancialStatementTemplate is then the top window so that it can be printed.
how do i set the focus on this specific window?
Thanks in advance.
Kev
I have a button that has to export 4 queries into excel spreadsheets, and then open an excel spreadsheet that has links to the 4 exports and does some nuber crunching and produces a report.
the button code is:
Dim fullpath As String
fullpath = CurrentProject.Path
' exports expenditure
DoCmd.OutputTo acQuery, "qryExpenditureExport", "MicrosoftExcelBiff8(*.xls)", fullpath & "\Exp.xls", True, "", 0
' exports income
DoCmd.OutputTo acQuery, "qryIncomeExport", "MicrosoftExcelBiff8(*.xls)", fullpath & "\In.xls", True, "", 0
' exports priority debts
DoCmd.OutputTo acQuery, "qryPriorityDebtsExport", "MicrosoftExcelBiff8(*.xls)", fullpath & "\PRIO.xls", True, "", 0
' exports non priority debts
DoCmd.OutputTo acQuery, "qryNPDExport", "MicrosoftExcelBiff8(*.xls)", fullpath & "\NPD.xls", True, "", 0
' Access form button
Call OpenSpecific_xlFile
It calls this code to open the file:
Sub OpenSpecific_xlFile()
' Late Binding (Needs no reference set)
Dim oXL As Object
Dim oExcel As Object
Dim sfullpath As String
Dim sPath As String
' Create a new Excel instance
Set oXL = CreateObject("Excel.Application")
' Only XL 97 supports UserControl Property
On Error Resume Next
oXL.UserControl = True
On Error GoTo 0
' Full path of excel file to open
On Error GoTo ErrHandle
sfullpath = CurrentProject.Path & "\FinancialStatementTemplate.xlt"
' Open it
With oXL
.Visible = True
.Workbooks.Open (sfullpath)
End With
ErrExit:
Set oXL = Nothing
Exit Sub
ErrHandle:
oXL.Visible = False
MsgBox Err.Description
GoTo ErrExit
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Run it from a form button
Private Sub cmdOpenExcelFIle_Click()
' Access form button
Call OpenSpecific_xlFile
I need to then make sure that FinancialStatementTemplate is then the top window so that it can be printed.
how do i set the focus on this specific window?
Thanks in advance.
Kev