print preview

  • Thread starter Thread starter nikolaosk
  • Start date Start date
N

nikolaosk

hi there folks!!!

i am working on a project that uses vba scripts to test features of

excel.


my problem is this.

i have to check if the user has inserted a header and aligned it right
in a specific worksheet.



i can do that no problem.


then i am asked to check if the user has hit the print preview button
and that the worksheet is in the print preview mode.



when i record a macro that puts a workesheet in print preview what i
get from the recorded macro is this


ActiveWindow.SelectedSheets.PrintPreview.



how can i check that the user has left his worksheet in print preview
mode?


i hope you understand


please help!!!!!!!!!
 
Nikolaos,

query the Printpreview property of the relevant sheet,
like this:

Dim PPviewOn as boolean

If activesheet.printpreview = true then
PPview = True
... your code here ...
Else
PPview = False
... alternative code here ...
End IF

Cheers, Pete
 
That always returned false for me - of course printpreview doesn't return
anything until the sheet is out of printprint preview.
 
Ah...

I didn't realise that, I just played around with querying
the value and setting it to true, then made up the rest of
my example without actually trying it. That should be a
lesson for me!

After a brief interlude, I now see that the VBE is
disabled when in Print preview mode. Is there any way for
Nikoloas to do what he wants?

Pete
 
I don't think the object model provides any direct way to do that. I
believe any workaround would depend on detecting the user initiating a
command that would take them into printpreview mode.

--
Regards,
Tom Ogilvy

Pete McCosh said:
Ah...

I didn't realise that, I just played around with querying
the value and setting it to true, then made up the rest of
my example without actually trying it. That should be a
lesson for me!

After a brief interlude, I now see that the VBE is
disabled when in Print preview mode. Is there any way for
Nikoloas to do what he wants?

Pete
 
Back
Top