Page 1 of 1 1
Topic Options
#188492 - 2008-07-01 08:46 AM Formatting Excel sheet (.pagesetup)
spocky184 Offline
Fresh Scripter

Registered: 2007-07-12
Posts: 5
Hi,
i have a little problem formatting an Excel sheet.
I am using this code:
$oXL.ActiveSheet.PageSetup.LeftHeader = "This is the left header"
$oXL.ActiveSheet.PageSetup.CenterHeader = ""
$oXL.ActiveSheet.PageSetup.RightHeader = @DATE
$oXL.ActiveSheet.PageSetup.LeftFooter = ""
$oXL.ActiveSheet.PageSetup.CenterFooter = ""
$oXL.ActiveSheet.PageSetup.RightFooter = "Page &P of &N"
$oXL.ActiveSheet.PageSetup.Orientation = 2
$oXL.ActiveSheet.PageSetup.Zoom = -1
$oXL.ActiveSheet.PageSetup.FitToPagesWide = 1
$oXL.ActiveSheet.PageSetup.FitToPagesTall = 50
$oXL.ActiveSheet.PageSetup.PrintTitleRows = "$$2:$$2"
$oXL.ActiveSheet.PageSetup.PrintTitleColumns = ""

Everything works fine except the following lines:

$oXL.ActiveSheet.PageSetup.FitToPagesWide = 1
$oXL.ActiveSheet.PageSetup.FitToPagesTall = 50

I have monitored a macro in Excel and there is the following line:

.ActiveSheet.PageSetup.Zoom = False

Maybe that is my problem !? I have tried different variations of the line but nothing worked:

$oXL.ActiveSheet.PageSetup.Zoom = "False"
$oXL.ActiveSheet.PageSetup.Zoom = -1
$oXL.ActiveSheet.PageSetup.Zoom = 0

Any idea ?

Greetings
spocky184

Top
#188500 - 2008-07-01 05:44 PM Re: Formatting Excel sheet (.pagesetup) [Re: spocky184]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
What version of Excel are you working with?

XL2000: FitToPagesWide or FitToPagesTall Does Not Affect Page Setup

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#188501 - 2008-07-01 05:50 PM Re: Formatting Excel sheet (.pagesetup) [Re: spocky184]
spocky184 Offline
Fresh Scripter

Registered: 2007-07-12
Posts: 5
I am using Excel 2003 SP3.
I think the problem is to "convert" the boolean true or false of
.PageSetup.Zoom
Is there any way to do it in kix ?
If i use $oXL.ActiveSheet.PageSetup.Zoom = 50 it works just fine,
but i can't use
$oXL.ActiveSheet.PageSetup.FitToPagesWide = 1
$oXL.ActiveSheet.PageSetup.FitToPagesTall = 50

Greetings
spocky184

Top
#188502 - 2008-07-01 06:01 PM Re: Formatting Excel sheet (.pagesetup) [Re: spocky184]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I am kind of curious why you chose the value of 50? Looking at http://www.spreadsheetgear.com/support/h...oPagesTall.html

We see this as a boolean (on or off)..

Am I missing something here?

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#188504 - 2008-07-01 08:19 PM Re: Formatting Excel sheet (.pagesetup) [Re: Kdyer]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Use NOT for boolean true/false.

$object.property = NOT 0 ; true
$object.property = NOT 1 ; false
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#188509 - 2008-07-02 09:45 AM Re: Formatting Excel sheet (.pagesetup) [Re: Les]
spocky184 Offline
Fresh Scripter

Registered: 2007-07-12
Posts: 5
thanx Les! that works fine !
my code line is now:
$oXL.ActiveSheet.PageSetup.Zoom = Not 1
$oXL.ActiveSheet.PageSetup.FitToPagesWide = 1
$oXL.ActiveSheet.PageSetup.FitToPagesTall = 50

(i am using 50 because i don`t know on runtime how many pages my excel sheet will create, but i like all the pages to be exactly 1 page wide)

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 405 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.157 seconds in which 0.094 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org