Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default print previw

hi there!!! i am working on a project that i need to know if the user
has hit the print preview button to print preview a page.

the main idea is this. the user is asked to write something and then
print preview the worksheet he has made the change and LEAVE THE ACTIVE
WINDOW IN THE PRINT PREVIEW MODE.


as you know when the active window is in the print preview mode nothing
runs behind-in the vba editor. i mean if you change back to the vba
editor while in print preview mode and hit the f5 button it will
freeze.

what i am thinking is this: there must be an event(hope so) that we can
check if the user has hit the print preview button.

then capture the event and if the user has hit the preview buttonh gets
a correct answer otherwise he fails.

this is a workaround. i do not know how to capture that event or if VB
gives me access to these events programatically.

please help



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default print previw

Hi,

handle the WorkbookBeforeSave event (fired for a preview
as well as for print).

In case you are new to event handling in VBA: You need to
create a class module with a reference to the object
instance which events you are handling (in this case an
instance of the Excel application). The following snippet
should get you started:

' --- Class module AppEvents

Dim WithEvents app as Excel.Application

Sub Class_Initialize()
Set app = Application
End Sub

Sub app_WorkbookBeforePrint(wb As Workbook, Cancel As
Boolean)
MsgBox "Workbook named " & wb.Name & " will print."
End Sub


'-- In any standard module

Dim eventHandlerObj As New AppEvents

When your standard module is parsed, eventHandlerObj is
assigned a new instance of the AppEvents class module.
That fires the Class_Initialize in the class module,
assigning the private field app to the current application
instance. Subsequently, when Excel is about to print or
preview, the beforeprint event fires. You can cancel
printing by setting the parameter Cancel to false in the
handler.

Hope this is helpful. Best regards,

Dag Johansen

-----Original Message-----
hi there!!! i am working on a project that i need to know

if the user
has hit the print preview button to print preview a page.

the main idea is this. the user is asked to write

something and then
print preview the worksheet he has made the change and

LEAVE THE ACTIVE
WINDOW IN THE PRINT PREVIEW MODE.


as you know when the active window is in the print

preview mode nothing
runs behind-in the vba editor. i mean if you change back

to the vba
editor while in print preview mode and hit the f5 button

it will
freeze.

what i am thinking is this: there must be an event(hope

so) that we can
check if the user has hit the print preview button.

then capture the event and if the user has hit the

preview buttonh gets
a correct answer otherwise he fails.

this is a workaround. i do not know how to capture that

event or if VB
gives me access to these events programatically.

please help



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default print previw

Hi,

I fail to see the point of your question:

If no macro can be run whilst in preview mode, why would
you need an event to detect that state?

I cannot open (or activate) the VBE when a workbook is in
preview mode.

I know only one way to provoke a macro to run whilst in
print Preview, which is by using the SetTimer API.

Regards,

Jan Karel Pieterse
Excel TA/MVP

-----Original Message-----
hi there!!! i am working on a project that i need to know

if the user
has hit the print preview button to print preview a page.

the main idea is this. the user is asked to write

something and then
print preview the worksheet he has made the change and

LEAVE THE ACTIVE
WINDOW IN THE PRINT PREVIEW MODE.


as you know when the active window is in the print

preview mode nothing
runs behind-in the vba editor. i mean if you change back

to the vba
editor while in print preview mode and hit the f5 button

it will
freeze.

what i am thinking is this: there must be an event(hope

so) that we can
check if the user has hit the print preview button.

then capture the event and if the user has hit the

preview buttonh gets
a correct answer otherwise he fails.

this is a workaround. i do not know how to capture that

event or if VB
gives me access to these events programatically.

please help



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default print previw

Dag,

You said beforesave and then illustrated with beforeprint which is what I
assume you meant anyway.

Also, what you show is to instantiate application level events. Each
individual workbook has its own beforeprint event which does not require
setting up a class module. It depends on what the original poster wants to
achieve - in any event, there isn't any builtin attribute to determine if
the user is going into printpreview or actually printing.

It is also unclear what the original poster hopes to achieve in terms of
detecting if the user is in printpreview mode. The user has limited
capabilties in print preview, so not sure what control is trying to be
exercised. If it is absolutely important to the application, the original
poster could cancel the print/printpreview and put up a dialog to have the
user tell the application what they are trying to do (print or print
preview, then the application would know and control what happens before or
after - obviously there is no control while printing or in print preview).

--
Regards,
Tom Ogilvy


"Dag Johansen" wrote in message
...
Hi,

handle the WorkbookBeforeSave event (fired for a preview
as well as for print).

In case you are new to event handling in VBA: You need to
create a class module with a reference to the object
instance which events you are handling (in this case an
instance of the Excel application). The following snippet
should get you started:

' --- Class module AppEvents

Dim WithEvents app as Excel.Application

Sub Class_Initialize()
Set app = Application
End Sub

Sub app_WorkbookBeforePrint(wb As Workbook, Cancel As
Boolean)
MsgBox "Workbook named " & wb.Name & " will print."
End Sub


'-- In any standard module

Dim eventHandlerObj As New AppEvents

When your standard module is parsed, eventHandlerObj is
assigned a new instance of the AppEvents class module.
That fires the Class_Initialize in the class module,
assigning the private field app to the current application
instance. Subsequently, when Excel is about to print or
preview, the beforeprint event fires. You can cancel
printing by setting the parameter Cancel to false in the
handler.

Hope this is helpful. Best regards,

Dag Johansen

-----Original Message-----
hi there!!! i am working on a project that i need to know

if the user
has hit the print preview button to print preview a page.

the main idea is this. the user is asked to write

something and then
print preview the worksheet he has made the change and

LEAVE THE ACTIVE
WINDOW IN THE PRINT PREVIEW MODE.


as you know when the active window is in the print

preview mode nothing
runs behind-in the vba editor. i mean if you change back

to the vba
editor while in print preview mode and hit the f5 button

it will
freeze.

what i am thinking is this: there must be an event(hope

so) that we can
check if the user has hit the print preview button.

then capture the event and if the user has hit the

preview buttonh gets
a correct answer otherwise he fails.

this is a workaround. i do not know how to capture that

event or if VB
gives me access to these events programatically.

please help



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/

.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print and Print Preview Graphic Moving Resizing 2007/2003 Adam Rayburn Excel Discussion (Misc queries) 0 April 4th 07 04:18 PM
cell borders that I create dont show on print preview or print scott3435 Excel Discussion (Misc queries) 2 April 6th 06 02:37 AM
Pivot Table macro to set print area and print details of drill down data Steve Haskins Excel Discussion (Misc queries) 2 December 28th 05 04:59 PM
Active cell counting in particular print page (one sheet having different print area) ananthmca2004 Excel Worksheet Functions 1 November 24th 05 11:29 AM
Create a print macro that would automatically select print area? wastedwings Excel Worksheet Functions 7 August 22nd 05 10:36 PM


All times are GMT +1. The time now is 03:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"