Print area - Message box

A

al

Can someone correct macro below pls - why is my "false" input not
working - thxs


Sub Printseuplandscape()
'
'
Dim Fitp
Application.ScreenUpdating = False
'
ActiveSheet.Pagesetup.PrintArea = ActiveRange
With ActiveSheet.Pagesetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.Pagesetup.PrintArea = Selection.Address
With ActiveSheet.Pagesetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = "&D-&T"
.CenterFooter = "&P of &N"
.RightFooter = "&Z&F-&F-&A"
 
W

ward376

It looks like your trying to use a string where a boolean value is
required.

Sub Printseuplandscape()
'
'
Dim Fitpg
Application.ScreenUpdating = False
'
'ActiveSheet.PageSetup.PrintArea = ActiveRange
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = Selection.Address
With ActiveSheet.PageSetup
' .LeftHeader = ""
' .CenterHeader = ""
' .RightHeader = ""
.LeftFooter = "&D-&T"
.CenterFooter = "&P of &N"
.RightFooter = "&Z&F-&F-&A"
.FitToPagesWide = 1


Fitpg = Application.InputBox _
(Prompt:="To fit to 1 page type 1, otherwise click cancel",
Default:="", Title:="Fit to page tall", Type:=1)


.FitToPagesTall = Fitpg
' .PrintErrors = xlPrintErrorsDisplayed
End With
Application.ScreenUpdating = True
End Sub

Keep an eye on your spelling also.

Cliff Edwards
 
A

al

It looks like your trying to use a string where a boolean value is
required.

Sub Printseuplandscape()
'
'
Dim Fitpg
Application.ScreenUpdating = False
'
'ActiveSheet.PageSetup.PrintArea = ActiveRange
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = Selection.Address
With ActiveSheet.PageSetup
' .LeftHeader = ""
' .CenterHeader = ""
' .RightHeader = ""
.LeftFooter = "&D-&T"
.CenterFooter = "&P of &N"
.RightFooter = "&Z&F-&F-&A"
.FitToPagesWide = 1

Fitpg = Application.InputBox _
(Prompt:="To fit to 1 page type 1, otherwise click cancel",
Default:="", Title:="Fit to page tall", Type:=1)

.FitToPagesTall = Fitpg
' .PrintErrors = xlPrintErrorsDisplayed
End With
Application.ScreenUpdating = True
End Sub

Keep an eye on your spelling also.

Cliff Edwards

i know its wrong but What correction do i need to make for it to work??
 
J

jayray

Or as ward376 indicated, just set the Default as "", rather than the
"False" you had entered.
 
J

john

as user only has two choices (yes or no) try using a message box.

Sub Printseuplandscape()

Dim Fitp As Variant
Application.ScreenUpdating = False

With ActiveSheet

.PageSetup.PrintArea = ActiveRange

With .PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With

.PageSetup.PrintArea = Selection.Address

With .PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = "&D-&T"
.CenterFooter = "&P of &N"
.RightFooter = "&Z&F-&F-&A"
.FitToPagesWide = 1

msg = MsgBox("Do you want to Fit to one page?", 36, "Page setUp")

If msg = 6 Then
fitpg = 1
Else
fitpg = False
End If

.FitToPagesTall = fitpg
.PrintErrors = xlPrintErrorsDisplayed

End With

End With
Application.ScreenUpdating = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top