Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default PageSetup.Zoom=TRUE

I have a worksheet with e.g. 25 pages. I want to set the Zoom value that e.g.
4 of the original pages fit to one new page via VBA.
For this I select 4 original pages, define this range as PrintArea and set
the Pagesetup to Fit to 1 page wide by 1 page tall with FitToPagesWide and
FitToPagesTall. Before I have to set .Zoom to FALSE.
With this setting the Zoom value is set to e.g. 34%. Then I want to set
Zoom=True and select the whole sheet as PrintArea.
Question: How can I read out the Zoom value als long as Zoom=False, or how
can I set Zoom=True without setting a specific Zoom value?
Thanks in advance for all helps.

Regards
reklamo

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default PageSetup.Zoom=TRUE

Saved from a previous post...

Jim Rech collaborated with Nick Osdale-Popa to create this interesting code that
uses .printpreview.


Declare Function LockWindowUpdate Lib _
"user32" (ByVal hwndLock As Long) As Long
Declare Function FindWindowA Lib _
"user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Sub SetPageZoom()
Dim ZoomFactor As Integer
Dim hWnd As Long

hWnd = FindWindowA("XLMAIN", Application.Caption)
LockWindowUpdate hWnd 'see note below

With ActiveSheet.PageSetup
.FitToPagesTall = False
.FitToPagesWide = 1
.Zoom = False
End With
'in order to calculate the Zoom %, a PrintPreview must initiated.
SendKeys "%C"
ActiveSheet.PrintPreview
'to get/set the Zoom %, initiate the Page Setup Dialog box.
SendKeys "P%A~"
Application.Dialogs(xlDialogPageSetup).Show
ZoomFactor = ActiveSheet.PageSetup.Zoom
ActiveSheet.PageSetup.Zoom = ZoomFactor

LockWindowUpdate 0 'see note below
End Sub

The lockwindowupdate will suppress any screen flicker. But if something goes
wrong, it's reboot time. I wouldn't use them. I'd live with minor flashing.

reklamo wrote:

I have a worksheet with e.g. 25 pages. I want to set the Zoom value that e.g.
4 of the original pages fit to one new page via VBA.
For this I select 4 original pages, define this range as PrintArea and set
the Pagesetup to Fit to 1 page wide by 1 page tall with FitToPagesWide and
FitToPagesTall. Before I have to set .Zoom to FALSE.
With this setting the Zoom value is set to e.g. 34%. Then I want to set
Zoom=True and select the whole sheet as PrintArea.
Question: How can I read out the Zoom value als long as Zoom=False, or how
can I set Zoom=True without setting a specific Zoom value?
Thanks in advance for all helps.

Regards
reklamo


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default PageSetup.Zoom=TRUE

Hi Dave

Thanks so much for your prompt help. It's working great.

Regards
reklamo


"Dave Peterson" wrote:

Saved from a previous post...

Jim Rech collaborated with Nick Osdale-Popa to create this interesting code that
uses .printpreview.


Declare Function LockWindowUpdate Lib _
"user32" (ByVal hwndLock As Long) As Long
Declare Function FindWindowA Lib _
"user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Sub SetPageZoom()
Dim ZoomFactor As Integer
Dim hWnd As Long

hWnd = FindWindowA("XLMAIN", Application.Caption)
LockWindowUpdate hWnd 'see note below

With ActiveSheet.PageSetup
.FitToPagesTall = False
.FitToPagesWide = 1
.Zoom = False
End With
'in order to calculate the Zoom %, a PrintPreview must initiated.
SendKeys "%C"
ActiveSheet.PrintPreview
'to get/set the Zoom %, initiate the Page Setup Dialog box.
SendKeys "P%A~"
Application.Dialogs(xlDialogPageSetup).Show
ZoomFactor = ActiveSheet.PageSetup.Zoom
ActiveSheet.PageSetup.Zoom = ZoomFactor

LockWindowUpdate 0 'see note below
End Sub

The lockwindowupdate will suppress any screen flicker. But if something goes
wrong, it's reboot time. I wouldn't use them. I'd live with minor flashing.

reklamo wrote:

I have a worksheet with e.g. 25 pages. I want to set the Zoom value that e.g.
4 of the original pages fit to one new page via VBA.
For this I select 4 original pages, define this range as PrintArea and set
the Pagesetup to Fit to 1 page wide by 1 page tall with FitToPagesWide and
FitToPagesTall. Before I have to set .Zoom to FALSE.
With this setting the Zoom value is set to e.g. 34%. Then I want to set
Zoom=True and select the whole sheet as PrintArea.
Question: How can I read out the Zoom value als long as Zoom=False, or how
can I set Zoom=True without setting a specific Zoom value?
Thanks in advance for all helps.

Regards
reklamo


--

Dave Peterson
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hi DaveThanks so much for your prompt help. it is working great.

I found the following Excel4 code at http://www.ozgrid.com/forum/showthre...t=49644&page=1

Andy Pope - OzMVP (Roobarb) - March 2003

that gets round having to do the PrintPreview, assuming that the zoom factor has been determined, but is just not accessible, as Zoom is off, and Fit to is on:

Use

Application.ExecuteExcel4Macro "PAGE.SETUP(,,,,,,,,,,,,{1,#N/A})"
Application.ExecuteExcel4Macro "PAGE.SETUP(,,,,,,,,,,,,{#N/A,#N/A})"

to switch zoom on, allowing you to pick up the factor.

If you have previously stored the Tall and Wide settings, you can then reinstate Zoom to false, and then Tall and Wide.

I've used this to rescale footers according to the degree of zoom.

Trust this helps.

Peter

On Thursday, December 17, 2009 1:21 AM reklamo wrote:


I have a worksheet with e.g. 25 pages. I want to set the Zoom value that e.g.
4 of the original pages fit to one new page via VBA.
For this I select 4 original pages, define this range as PrintArea and set
the Pagesetup to Fit to 1 page wide by 1 page tall with FitToPagesWide and
FitToPagesTall. Before I have to set .Zoom to FALSE.
With this setting the Zoom value is set to e.g. 34%. Then I want to set
Zoom=True and select the whole sheet as PrintArea.
Question: How can I read out the Zoom value als long as Zoom=False, or how
can I set Zoom=True without setting a specific Zoom value?
Thanks in advance for all helps.

Regards
reklamo



On Thursday, December 17, 2009 8:41 AM Dave Peterson wrote:


Saved from a previous post...

Jim Rech collaborated with Nick Osdale-Popa to create this interesting code that
uses .printpreview.


Declare Function LockWindowUpdate Lib _
"user32" (ByVal hwndLock As Long) As Long
Declare Function FindWindowA Lib _
"user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Sub SetPageZoom()
Dim ZoomFactor As Integer
Dim hWnd As Long

hWnd = FindWindowA("XLMAIN", Application.Caption)
LockWindowUpdate hWnd 'see note below

With ActiveSheet.PageSetup
.FitToPagesTall = False
.FitToPagesWide = 1
.Zoom = False
End With
'in order to calculate the Zoom %, a PrintPreview must initiated.
SendKeys "%C"
ActiveSheet.PrintPreview
'to get/set the Zoom %, initiate the Page Setup Dialog box.
SendKeys "P%A~"
Application.Dialogs(xlDialogPageSetup).Show
ZoomFactor = ActiveSheet.PageSetup.Zoom
ActiveSheet.PageSetup.Zoom = ZoomFactor

LockWindowUpdate 0 'see note below
End Sub

The lockwindowupdate will suppress any screen flicker. But if something goes
wrong, it is reboot time. I would not use them. I'd live with minor flashing.

reklamo wrote:

--

Dave Peterson



On Thursday, December 17, 2009 3:05 PM reklamo wrote:


Hi Dave

Thanks so much for your prompt help. it is working great.

Regards
reklamo


"Dave Peterson" wrote:



Submitted via EggHeadCafe
Entity Framework Code-First Library CTP 5 Quick Facts
http://www.eggheadcafe.com/tutorials...ick-facts.aspx

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
ActiveSheet.PageSetup.Zoom No Name Excel Programming 1 December 13th 05 10:24 PM
pagesetup.zoom problem !!! Olivier[_3_] Excel Programming 3 October 22nd 04 04:34 PM
Need Code to Set Scaling Zoom in PageSetup in Auto_Open Sub Phil Hageman[_3_] Excel Programming 3 April 20th 04 09:11 PM
read ZOOM after setting FitToPagesWide in pagesetup Dave Peterson[_3_] Excel Programming 1 September 3rd 03 11:45 AM
read ZOOM after setting FitToPagesWide in pagesetup richard daniels Excel Programming 1 September 2nd 03 02:07 PM


All times are GMT +1. The time now is 09:37 PM.

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

About Us

"It's about Microsoft Excel"