Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Feb 2004
    Location
    Houston, Texas, USA
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set Excel Margins from Project (2000/SR1)

    In my macro, I am using the following code to change the Excel PageSetup from a Project macro. However, none of the Margin commands are working, as commented below

    'Set up Excel page header and footer, orientation, margins, and titles
    With xlBook.Worksheets(1).PageSetup
    .LeftMargin = Application.InchesToPoints(0.5) 'does not work
    .RightMargin = Application.InchesToPoints(0.5) 'does not work
    .TopMargin = Application.InchesToPoints(0.5) 'does not work
    .BottomMargin = Application.InchesToPoints(0.5) 'does not work
    .HeaderMargin = Application.InchesToPoints(0.25) 'does not work
    .FooterMargin = Application.InchesToPoints(0.25) 'does not work
    .RightFooter = "&""Arial,Italic""xls1.Name"
    .CenterFooter = "&""Arial,Italic""&8Page &P of &N"
    .RightFooter = "&""Arial,Italic""&8&D &T"
    .Orientation = xlLandscape
    .PaperSize = xlPaperLegal
    .CenterHorizontally = True
    .PrintTitleRows = "$1:$5"
    .PrintTitleColumns = "A$:E$"
    End With

    Does anyone know why margins won't reset when everything else does?

    Thanks,
    Caroline

  2. #2
    Star Lounger
    Join Date
    Feb 2004
    Location
    Houston, Texas, USA
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set Excel Margins from Project (2000/SR1)

    Thanks, I'll try it!

    Caroline

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Set Excel Margins from Project (2000/SR1)

    <P ID="edit" class=small>(Edited by sdckapr on 27-Feb-04 11:10. Fixed typo)</P>If you are calling this code from Project, then the "Application" in your code is Project not excel. You need to refer to the excel "application"

    Do you have some code in that macro that "create"s or "Get"s excel (eg. your variable name might be different)

    Set xlApp = CreateObject("Excel.Application")
    or
    Set xlApp = Getobject(, "Excel.Application")

    replace all the "Application.xxx"

    with "xlApp.xxx"

    Also the dollar signs are in the wrong place in the "printcolumns" line: it should be:

    <pre>.PrintTitleColumns = "$A:$E"</pre>



    Steve

  4. #4
    Star Lounger
    Join Date
    Feb 2004
    Location
    Houston, Texas, USA
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set Excel Margins from Project (2000/SR1)

    It worked. I had the "Get" code already so when I changed the rest, it ran perfectly.

    Thanks again,
    Caroline

  5. #5
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Set Excel Margins from Project (2000/SR1)

    Glad that it worked out and that I could be of help.

    Steve

  6. #6
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Set Excel Margins from Project (2000/SR1)

    Thanks for the help Steve.
    Regards,

    Gary
    (It's been a while!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •