У меня есть следующий код:
Sub PrintSheet()
' Print sent to Print Preview so user can check output and send it to
' the desired printer!
If Range("Committee_Name") <> "" Then
ActiveWindow.SelectedSheets.PrintPreview
Else
With ActiveSheet.PageSetup
.PrintTitleRows = "$14:$16"
.PrintTitleColumns = ""
.CenterHeader = _
"&""Verdana,Regular""&16WPOA: Longe Range Planning Committee Summary"
.CenterFooter = "Page &P of &N"
.RightFooter = "as of: &D"
.LeftMargin = Application.InchesToPoints(0.3)
.RightMargin = Application.InchesToPoints(0.3)
.TopMargin = Application.InchesToPoints(0.7)
End With
'The True argument to PrintPreview allows the Print Dialog to appear.
'w/o this argument it goes right to the default printer.
'However, for some reason it is not necessary in the code above!
Range("Data_Table").PrintPreview (True)
End If
End Sub 'PrintSheet
В ветви True окна If, когда отображается предварительный просмотр, и я нажимаю кнопку «Печать», я получаю диалоговое окно печати, как ожидалось. Однако в ветви False (Else), если я не включаю параметр True для изменений, он переходит непосредственно на мой принтер по умолчанию без отображения диалогового окна. Казалось бы, это вызвано включением кода PrintSetup, но почему?