Mike Eghtebas
asked on
Print Area in excel from vb6 form
I am opening an excel file from a vb 6 form. I want code to do foolowing:
1. Determine if there is a print area is set.
2. If there is no print area, locate the last cell(s) and set a print area.
2. Change View/Normal setting to View/Page Break Review.
Thanks
1. Determine if there is a print area is set.
2. If there is no print area, locate the last cell(s) and set a print area.
2. Change View/Normal setting to View/Page Break Review.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How about: <3. Change View/Normal setting to View/Page Break Review.>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ActiveWindow.View = xlPageBreakPreview
ActiveWindow.View = xlNormalView
Private Sub SetPA()
Dim xlApp As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Set xlApp = CreateObject("Excel.applic ation")
Dim pa As String
Set wb = xlApp.Workbooks.open("file name")
Set ws = wb.ActiveSheet
pa = ws.PageSetup.PrintArea
If pa = "" Then
With ws.PageSetup
.PrintArea = ws.UsedRange.Address
End With
End If
ActiveWindow.View = xlPageBreakPreview
Set ws = Nothing
Set wb = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub
ActiveWindow.View = xlNormalView
Private Sub SetPA()
Dim xlApp As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Set xlApp = CreateObject("Excel.applic
Dim pa As String
Set wb = xlApp.Workbooks.open("file
Set ws = wb.ActiveSheet
pa = ws.PageSetup.PrintArea
If pa = "" Then
With ws.PageSetup
.PrintArea = ws.UsedRange.Address
End With
End If
ActiveWindow.View = xlPageBreakPreview
Set ws = Nothing
Set wb = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub
Private Sub SetPA()
Dim xlApp As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Set xlApp = CreateObject("Excel.applic
Dim pa As String
Set wb = xlApp.Workbooks.open("file
Set ws = wb.ActiveSheet
pa = ws.PageSetup.PrintArea
If pa = "" Then
With ws.PageSetup
.PrintArea = ws.UsedRange.Address
End With
End If
Set ws = Nothing
Set wb = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub