Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default O2K code in XP - what gives?


I have a small macro that I wrote in Office2K that does some page setup
stuff - basically it sets the orientation, the margins to max, adds a
footer, and sets printing to 1 page wide (by x long).

Having just migrated from NT/Office2K to XP/Office2003 I now find that the
macro doesn't work - actually it does, but nothing happens (if that makes
sense...)

I tried recording the same actions to see where things had changed but the
only difference was that the recorded macro used .InchesToPoints instead of
the .CentimetersToPoints from my original code (see below)

my original code looks like this -

Sub PPSetup(appto As String, orient As String)
Dim i As Integer

For i = 1 To ActiveWorkbook.Sheets.Count
With Sheets(i).PageSetup
.LeftFooter = "&8&F - &8&A"
.CenterFooter = "&8&P of &N"
.RightFooter = "printed &T-&D"
.LeftMargin = Application.CentimetersToPoints(0.5)
.RightMargin = Application.CentimetersToPoints(0.5)
.TopMargin = Application.CentimetersToPoints(0.5)
.BottomMargin = Application.CentimetersToPoints(1)
.HeaderMargin = Application.CentimetersToPoints(0.5)
.FooterMargin = Application.CentimetersToPoints(0.5)
.TopMargin = Application.CentimetersToPoints(0.5)
.PrintGridlines = True
.Orientation = orient
.PaperSize = xlPaperA4
.Order = xlDownThenOver
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
If appto = "Sht" Then Exit For
Next i
End Sub

and the ('cleaned') recorded macro looks like this

Sub Marco1()
With ActiveSheet.PageSetup
.LeftFooter = "&F"
.CenterFooter = "&P of &N"
.RightFooter = "&A"
.LeftMargin = Application.InchesToPoints(0.196850393700787)
.RightMargin = Application.InchesToPoints(0.196850393700787)
.TopMargin = Application.InchesToPoints(0.196850393700787)
.BottomMargin = Application.InchesToPoints(0.393700787401575)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0.196850393700787)
.PrintGridlines = True
.PrintQuality = 600
.Orientation = xlLandscape
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
.PrintErrors = xlPrintErrorsDisplayed
End With
End Sub

My original sub is called via a small form that prompts the user for the
preferred orientation (portrait or landscape), and whether or not they want
to apply the setup to just the active sheet, or to all the sheets in the
active workbook

any/all suggestions would be appreciated (cos I've got no idea...)

TIA

S

--
there are only 10 types of people in this world,
those who understand binary, and those who don't...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default O2K code in XP - what gives?

Hi Simon,

your original code works for me if I change type of "orient" to long
(excel expect one of constants xlLandscape = 2 or xlPortrait = 1).

Regards,
Ivan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default O2K code in XP - what gives?

sorry, forgot to mention that I am using XP/O2003

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default O2K code in XP - what gives?

In our last episode Ivan Raiminius wrote:

sorry, forgot to mention that I am using XP/O2003


Ivan

many thanks, I noticed that yesterday afternoon, but figured that it
wouldn't make that much difference as many properties use/accept both
literal and numeric index values

actually, I have to admit it was my bad - the problem was with the loop, ie
it always started at the first sheet. It dawned on me last nite. I guess
that's the problem with writing stuff that you don't use yourself...

In case anyone's interested, the fix was to get the activesheet index, then
pass that to the existing loop so that if the user is only setting up a
single sheet the loop will start at the active sheet...

<snip

If appto = "Sht" Then ShtIndex = ActiveSheet.Index Else ShtIndex = 1

For i = ShtIndex To ActiveWorkbook.Sheets.Count

</snip

many thanks

S
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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
do anybody have a sample code for executing excel macro from vb code?<eom B Deepak Excel Programming 2 September 30th 05 09:59 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM


All times are GMT +1. The time now is 09:48 AM.

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"