Getting Zoom Factor

  • Thread starter Thread starter HA
  • Start date Start date
H

HA

Hi,

Is there any possiblity to get zooming factor page setup if .zoom property set to false/true

thanks.

HA
 
the following line will return the zoom percentage

MsgBox ActiveSheet.PageSetup.Zoom
 
activewindow.Zoom

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

Hi,

Is there any possiblity to get zooming factor page setup if .zoom property
set to false/true

thanks.

HA
 
Sorry for describing the problem on wrong way...

With ActiveSheet.PageSetup
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With


the problem is when fit to pages wide and tall selected from page setup (as you see in the code), zoom property set to false automatically.
if fit to page selected, with vba code ActiveSheet.PageSetup.Zoom returns False.
But from page setup dialog box, we can see the zoom factor.
I just want to know on that circumstance, is ther any possiblity to get zoom factor.

thanks...

--
HA
"Bob Phillips" <[email protected]>, haber iletisinde þunlarý yazdý:[email protected]...
activewindow.Zoom

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

Hi,

Is there any possiblity to get zooming factor page setup if .zoom property
set to false/true

thanks.

HA
 
I don't think there is a way of getting what you want - zoom is a value
if true, or false if false, if false, then excel calculates on the fly
I think.
 
I have never used it, but this was posted in the past:

Here's a post from Jim Rech/Nick Osdale-Popa.

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


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
End Sub
 
Hi,
try this:

Sub Test()
Dim vRet As Variant

'FitToPagesWide <-- 1
'FitToPagesTall <-- 1
vRet = ExecuteExcel4Macro("PAGE.SETUP(,,,,,,,,,,,,{1,1})")

'Select the Zoom option
vRet = ExecuteExcel4Macro("PAGE.SETUP(,,,,,,,,,,,,{#N/A,#N/A})")

'Get the Zoom value
MsgBox ActiveSheet.PageSetup.Zoom
'or
'vRet = ExecuteExcel4Macro("GET.DOCUMENT(62)")
End Sub
 
Hi,

Thanks for the code. I have one more question.

Is there any way to use that code in a User Defined Function.

thanks in advance...

--
HA

"okaizawa" <[email protected]>, haber iletisinde ?unlar? yazd?:[email protected]...
Hi,
try this:

Sub Test()
Dim vRet As Variant

'FitToPagesWide <-- 1
'FitToPagesTall <-- 1
vRet = ExecuteExcel4Macro("PAGE.SETUP(,,,,,,,,,,,,{1,1})")

'Select the Zoom option
vRet = ExecuteExcel4Macro("PAGE.SETUP(,,,,,,,,,,,,{#N/A,#N/A})")

'Get the Zoom value
MsgBox ActiveSheet.PageSetup.Zoom
'or
'vRet = ExecuteExcel4Macro("GET.DOCUMENT(62)")
End Sub
 
Function ZoomFactor()
ZoomFactor = Windows(Application.Caller.Parent.Parent.Name).Zoom
End Function


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

Hi,

Thanks for the code. I have one more question.

Is there any way to use that code in a User Defined Function.

thanks in advance...

--
HA

"okaizawa" <[email protected]>, haber iletisinde ?unlar?
yazd?:[email protected]...
Hi,
try this:

Sub Test()
Dim vRet As Variant

'FitToPagesWide <-- 1
'FitToPagesTall <-- 1
vRet = ExecuteExcel4Macro("PAGE.SETUP(,,,,,,,,,,,,{1,1})")

'Select the Zoom option
vRet = ExecuteExcel4Macro("PAGE.SETUP(,,,,,,,,,,,,{#N/A,#N/A})")

'Get the Zoom value
MsgBox ActiveSheet.PageSetup.Zoom
'or
'vRet = ExecuteExcel4Macro("GET.DOCUMENT(62)")
End Sub

--
HTH,
okaizawa

Sorry for describing the problem on wrong way...

With ActiveSheet.PageSetup
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With


the problem is when fit to pages wide and tall selected from page setup
(as you see in the code), zoom property set to false automatically.
 
Sorry, I meant

Function ZoomFactor()
ZoomFactor = Worksheets(Application.Caller.Parent.Name).PageSetup.Zoom
End Function


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

Hi,

Thanks for the code. I have one more question.

Is there any way to use that code in a User Defined Function.

thanks in advance...

--
HA

"okaizawa" <[email protected]>, haber iletisinde ?unlar?
yazd?:[email protected]...
Hi,
try this:

Sub Test()
Dim vRet As Variant

'FitToPagesWide <-- 1
'FitToPagesTall <-- 1
vRet = ExecuteExcel4Macro("PAGE.SETUP(,,,,,,,,,,,,{1,1})")

'Select the Zoom option
vRet = ExecuteExcel4Macro("PAGE.SETUP(,,,,,,,,,,,,{#N/A,#N/A})")

'Get the Zoom value
MsgBox ActiveSheet.PageSetup.Zoom
'or
'vRet = ExecuteExcel4Macro("GET.DOCUMENT(62)")
End Sub

--
HTH,
okaizawa

Sorry for describing the problem on wrong way...

With ActiveSheet.PageSetup
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With


the problem is when fit to pages wide and tall selected from page setup
(as you see in the code), zoom property set to false automatically.
 
Hi,

Thanks for the answer.
I'm trying to write a udf to calculate a cell or cell group width in cm. if .zoom property of PageSetup class not set to a logical value, I can calculate the width of cells in centimeter with the zoom ratio to see how it looks like on printout. The problem is if .zoom property set to false, I can not get the zoom ratio from PageSetup because it is calculated on fly.

I think, I give writing udf up and return to use workbook events.

Thanks a lot again....

--
HA
Is there any way to use that code in a User Defined Function.
I don't think it is possible in a cell formula.
how about Worksheet_Change or Worksheet_Calculate?

http://msdn.microsoft.com/library/en-us/vbaxl11/html/xlevtChange1_HV05199719.asp
http://msdn.microsoft.com/library/en-us/vbaxl11/html/xlevtCalculate1_HV05199619.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top