Setting zoom of a worksheet in macro

J

jhartley

Simple question it seems, but I can't find an answer.

I'm running a simulation macro for pricing optimization. Th
simulation results are written to a comma delimited file (I want t
archive it anyway) and then read into a new worksheet, where I generat
some summary statistics, make some charts, neatly align the charts
etc.

Everything up to this point works fine.

Next I would like to set the zoom on the new worksheet to 50% so tha
when the simulation is complete the user can see all the charts withou
having to scroll around (albeit smaller versions of the charts, whic
is OK).

Right now when the simulation is complete the results worksheet i
active - but it's at 100% zoom.

I tried using ActiveWindow.Zoom = 50 in the macro and I get a "run tim
error 1004, unable to set zoom property of the windows class." And a
any rate I only want to set the zoom for the active sheet, not th
whole workbook, which it seems is "the active window."

Tried also

Worksheets(Sheets.Count).PageSetup.zoom = 50

but it seems that only pertains to printing.

I appreciate any help!

Regards,

J
 
T

Tom Ogilvy

ActiveWindow.Zoom = 50
works fine and only sets the zoom for the activesheet in the activewindow.

It is unclear why you are having problems. It might have something to do
with where the focus is when you execute the command.
 
J

jhartley

Tom,

Thanks I'll double check the focus.

At least now I know what should work.

Cheers,

Jef
 
W

William

Jeff

Also, make sure you have a cell (or range of cells) activated when you run
the "Zoom" code - if a chart is selected the code "ActiveWindow.Zoom = 50"
will fail.

--
XL2002
Regards

William

(e-mail address removed)

| Tom,
|
| Thanks I'll double check the focus.
|
| At least now I know what should work.
|
| Cheers,
|
| Jeff
|
|
| ---
| Message posted
|
 

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

Top