Consulting

Results 1 to 6 of 6

Thread: Fit To pages wide

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Fit To pages wide

    [VBA]Activesheet.pagesetup.fittopageswide=1[/VBA]

    My code just runs through this code but it doesn't change anything. Why is that?

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hi Djblois,

    Do you set your pages to tall as well? What other code do you use? Have you tried doing this while recording a macro and getting your code?

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Any chnace you also have the Zoom property set?

  4. #4
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Firefyter

    I have tried it with code and it sets it to what the correct amount of pages but it doesn't enable it.

    XLD

    No, I don't have the zoom option on.

  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    You didn't really answer all of my questions either. Can you post your code?

  6. #6
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    [vba]Sub InvoiceProduct()

    'Add Fields to Pivot Table
    pt.AddFields RowFields:=Array("Invoice#", "Date", "Customer", "Cust#", "SlsPrsn", "Product", "Price ($)", "Unit Cost ($)")
    pt.PivotFields("Date").Subtotals = Array(False, False, False, False, False, False, _
    False, False, False, False, False, False)
    pt.PivotFields("Customer").Subtotals = Array(False, False, False, False, False, False, _
    False, False, False, False, False, False)
    pt.PivotFields("Cust#").Subtotals = Array(False, False, False, False, False, False, _
    False, False, False, False, False, False)
    pt.PivotFields("SlsPrsn").Subtotals = Array(False, False, False, False, False, False, _
    False, False, False, False, False, False)
    pt.PivotFields("Product").Subtotals = Array(False, False, False, False, False, False, _
    False, False, False, False, False, False)
    pt.PivotFields("Price ($)").Subtotals = Array(False, False, False, False, False, False, _
    False, False, False, False, False, False)
    pt.PivotFields("Unit Cost ($)").Subtotals = Array(False, False, False, False, False, False, _
    False, False, False, False, False, False)

    With pt.PivotFields("Cases")
    .Orientation = xlDataField
    .Function = xlSum
    .NumberFormat = "#,##0"
    .Name = "(Cases)"
    End With

    With pt.PivotFields("Units")
    .Orientation = xlDataField
    .Function = xlSum
    .NumberFormat = "#,##0"
    .Name = "(Units)"
    End With

    With pt.PivotFields("Amt ($)")
    .Orientation = xlDataField
    .Function = xlSum
    .NumberFormat = "#,##0"
    .Name = "(Amt ($))"
    End With

    With pt.PivotFields("Total Cost ($)")
    .Orientation = xlDataField
    .Function = xlSum
    .NumberFormat = "#,##0"
    .Name = "(Total Cost ($))"
    End With

    With pt.PivotFields("Profit ($)")
    .Orientation = xlDataField
    .Function = xlSum
    .NumberFormat = "#,##0"
    .Name = "(Profit ($))"
    End With

    With pt.PivotFields("%")
    .Orientation = xlDataField
    .Function = xlAverage
    .NumberFormat = "0.00%"
    .Name = "(%)"
    End With

    With pt.DataPivotField
    .Orientation = xlColumnField
    .Position = 1
    End With

    'Highlight Cust Totals
    pvt.Activate
    pt.ManualUpdate = False
    pt.PivotSelect "Invoice#[All;Total]", xlDataAndLabel, True
    Selection.Interior.ColorIndex = 15
    Selection.Font.Bold = True

    Range("IV2").Select
    Selection.End(xlToLeft).Select
    Range(Selection, Selection.End(xlToLeft)).Select
    With Selection
    .HorizontalAlignment = xlCenter
    .Font.Bold = True
    .Font.ColorIndex = 2
    .Interior.ColorIndex = 5
    .WrapText = True
    End With

    'set printheading
    With ActiveSheet.PageSetup
    .LeftHeader = "&""Arial,Bold""&12Atalanta"
    .CenterHeader = "&""Arial,Bold&12""&A"
    .LeftFooter = "&""Arial,Bold""&D &T " & Application.UserName
    .CenterFooter = "&""Arial,Bold""&F"
    .RightFooter = "&""Arial,Bold""Page &P of &N"
    .LeftMargin = Application.InchesToPoints(0.25)
    .RightMargin = Application.InchesToPoints(0.25)
    .TopMargin = Application.InchesToPoints(0.9)
    .BottomMargin = Application.InchesToPoints(0.6)
    .HeaderMargin = Application.InchesToPoints(0.3)
    .FooterMargin = Application.InchesToPoints(0.3)
    .PrintGridlines = True
    .CenterHorizontally = True
    .FitToPagesWide = 1
    .FitToPagesTall = False
    .PrintTitleRows = "$2:$2"
    .Orientation = xlLandscape
    End With

    Range("A3").Select
    ActiveWindow.FreezePanes = True
    End Sub[/vba]

    That is just some of the code. The whole thing is way too large to post.

Posting Permissions

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