Adjust worksheet print setup and margins:
.PageSetup.PrintTitleRows = “$5:$5”
.PageSetup.LeftFooter = “&F”
.PageSetup.CenterFooter = “”
.PageSetup.CenterHeader = “”
.PageSetup.RightFooter = “Page &P”
.PageSetup.Orientation = xlLandscape
.PageSetup.PrintGridlines = False
.PageSetup.Zoom = 90
End With
Make worksheet visible and save it:
appExcel.Application.Visible = True
strPrompt = _
“Enter file name and path for saving worksheet”
strTitle = “File name”
strDefault = strSaveName
strSaveName = InputBox(prompt:=strPrompt, _
Title:=strTitle, Default:=strDefault)
wkb.SaveAs FileName:=strSaveName, _
FileFormat:=xlWorkbookDefault
appExcel.Visible = True
ErrorHandlerExit:
Exit Function
ErrorHandler:
If Err = 429 Then
Excel is not running; open Excel with CreateObject:
Set appExcel = CreateObject(“Excel.Application”)
Resume Next
Else
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExit
End If
End Function
Part II Writing VBA Code to Exchange Data between Office Components