Hi All
I have written the following code to print data in excel sheet.It works fine but as its orientation is landscape so I want to align all the rows in the center.And also I want to set the header bold,underline and 16 size.
Can anyone please help me how to solve this.
Thanks
AMAn
I have written the following code to print data in excel sheet.It works fine but as its orientation is landscape so I want to align all the rows in the center.And also I want to set the header bold,underline and 16 size.
Code:
Set qdf = CurrentDb.CreateQueryDef("qrytemp", strsql)
Dim objXls As Excel.Application
Dim objWrkBk As Excel.Workbook
Dim xprtFile As String
xprtFile = "C:\Documents and Settings\Amanpreet Kaur\Desktop\rescansys.xls"
DoCmd.OutputTo acOutputQuery, "qrytemp", acFormatXLS, xprtFile, False
Set objXls = New Excel.Application
objXls.Visible = False
Const xlLandscape = 2
Set objWrkBk = objXls.Workbooks.Open(xprtFile)
objWrkBk.Sheets("qrytemp").Select
With objWrkBk.Sheets("qrytemp").PageSetup
.centerheader="MI Report"
.Orientation = xlLandscape
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
objWrkBk.PrintOut
objWrkBk.Close SaveChanges:=False
Set objWrkBk = Nothing
objXls.Quit
Set objXls = Nothing
Can anyone please help me how to solve this.
Thanks
AMAn