Hi Guys
I have written the following code that will print the rsult in excel sheet from access form print button. but my problem is result is not printing in one sheet .I can't change it manually from page setup in workbook as the following code creats a new sheet qrycombined in the existing workbook and print the result without saving it. How can i fit the result in one sheet or to change the layout from portrait to landscape.
Regards
Aman
I have written the following code that will print the rsult in excel sheet from access form print button. but my problem is result is not printing in one sheet .I can't change it manually from page setup in workbook as the following code creats a new sheet qrycombined in the existing workbook and print the result without saving it. How can i fit the result in one sheet or to change the layout from portrait to landscape.
Code:
Private Sub Command0_Click()
Dim objXls As Excel.Application
Dim objWrkBk As Excel.Workbook
Dim xprtFile As String
xprtFile = "C:\temp\combinded.xls"
DoCmd.OutputTo acOutputQuery, "qryCombined", acFormatXLS, xprtFile, False
Set objXls = New Excel.Application
objXls.Visible = False
Set objWrkBk = objXls.Workbooks.Open(xprtFile)
objWrkBk.PrintOut
objWrkBk.Close SaveChanges:=False
Set objWrkBk = Nothing
objXls.Quit
Set objXls = Nothing
End Sub
Regards
Aman