Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc,microsoft.public.excel.printing,microsoft.public.excel.programming
|
|||
|
|||
![]()
(sorry for the cross-posting)
<this could be useful I found no answer [other than Leo Huser] searching for in posts to several news groups [since 1997] on how to take PrintPreview in vba-control [an easy manner], so... The ONLY way "to control" PrintPreview is... = not to use PrintPreview!!! <= [as method] instead, it should be used [e.g.] = "UserResponse = Application.Dialogs(xlDialogPrintPreview). Show" given that showing a BuiltInDialog it will return False if canceled by the user [or by code] also, due to _BeforePrint event will be twice triggered [when "first-showing" PrintPreview] there will be necessary other [public boolean] variables "as support". Note: within _BeforePrint event, if Cancel is set to True, it will be "same-treated" = Canceled by user [or code] === in a normal code module === ' to detect if the process is "by code" or "normal" _ and if the user [or code] cancels PrintPreview / Print ' Public ViewByCode As Boolean, _ PrintByCode As Boolean, _ PrintedByCode As Boolean ' Test_macro ' Sub My_Preview() MsgBox "Starting PrintPreview [by code]..." ' <= this is optional ' ViewByCode = True PrintedByCode = Application.Dialogs(xlDialogPrintPreview).Show PrintByCode = False If Not PrintedByCode Then MsgBox "User [maybe code?] has CANCELED [print / preview]." End If End Sub === in ThisWorkbook code module === Private Sub Workbook_BeforePrint(Cancel As Boolean) If ViewByCode Then ViewByCode = False PrintByCode = True ElseIf PrintByCode Then MsgBox "Printing process [can be] controlled by code..." Else MsgBox "Printing process is [should it be?] ""normal""..." End If End Sub __HTH__ Regards, Héctor. MS-MVP [Mexico] |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
PrintPreview | Excel Discussion (Misc queries) | |||
MACRO: Catching only filled cell data | Excel Discussion (Misc queries) | |||
CATCHING DUPLICATE INFORMATION IN DIFFERENT CELLS SAME PROGRAM | Setting up and Configuration of Excel | |||
Print before close | Excel Discussion (Misc queries) | |||
ActiveX Controls moving upon print/printpreview | Excel Discussion (Misc queries) |