Windows Vista Forums

excel

  1. #1


    SammyL Guest

    excel

    I've tried many things here- one person insisted that window should be
    activewindow but i tried it both as activewindow and activesheet and i
    cannot set the hpagebreaks. if i just set the first pagebreak it
    doesn't return an error but does nothing- if i run 2 or more
    hpagebreaks it errors out with subscript out of range

    Dim xlapp
    Dim objWorkBook
    DIM XLWB
    Set xlapp = CreateObject("EXCEL.APPLICATION")
    Set objWorkBook = xlapp.Workbooks.Open("C:\test22.xls")
    Const xlLandScape = 2
    xlapp.ActiveSheet.PageSetup.Orientation = xlLandScape
    xlapp.ActiveSheet.PageSetup.FitToPagesWide = 1
    xlapp.ActiveSheet.PageSetup.FitToPagesTall = 99
    xlapp.ActiveSheet.ResetAllPageBreaks
    xlapp.ActiveSheet.Pagesetup.Zoom = False
    xlapp.ActiveWindow.Zoom = False
    xlapp.ActiveSheet.HPageBreaks(1).Location =
    xlapp.ActiveSheet.Range("A82")
    xlapp.ActiveSheet.HPageBreaks(2).Location =
    xlapp.ActiveSheet.Range("A183")
    'xlapp.ActiveSheet.HPageBreaks(3).Location =
    xlapp.ActiveSheet.Range("A272")
    'xlapp.ActiveSheet.HPageBreaks(4).Location =
    xlapp.ActiveSheet.Range("A324")


    objWorkBook.save
    Set objWorkBook = Nothing
    xlapp.Quit
    Set xlaPP= Nothing

    Tom- Thanks for all of your time and help. I tried replying to your
    verizon account but it doesnt seem to be reaching you.



      My System SpecsSystem Spec

  2. #2


    Tom Lavedas Guest

    Re: excel

    On May 6, 3:54*pm, SammyL <sam...@newsgroup> wrote:

    > I've tried many things here- one person insisted that window should be
    > activewindow but i tried it both as activewindow and activesheet and i
    > cannot set the hpagebreaks. if i just set the first pagebreak it
    > doesn't return an error but does nothing- if i run 2 or more
    > hpagebreaks it errors out with subscript out of range
    >
    > Dim xlapp
    > * * Dim objWorkBook
    > DIM XLWB
    > * * Set xlapp = CreateObject("EXCEL.APPLICATION")
    > * * Set objWorkBook = xlapp.Workbooks.Open("C:\test22.xls")
    > Const xlLandScape = 2
    > xlapp.ActiveSheet.PageSetup.Orientation = xlLandScape
    > xlapp.ActiveSheet.PageSetup.FitToPagesWide = 1
    > xlapp.ActiveSheet.PageSetup.FitToPagesTall = 99
    > xlapp.ActiveSheet.ResetAllPageBreaks
    > xlapp.ActiveSheet.Pagesetup.Zoom = False
    > xlapp.ActiveWindow.Zoom = False
    > xlapp.ActiveSheet.HPageBreaks(1).Location =
    > xlapp.ActiveSheet.Range("A82")
    > xlapp.ActiveSheet.HPageBreaks(2).Location =
    > xlapp.ActiveSheet.Range("A183")
    > 'xlapp.ActiveSheet.HPageBreaks(3).Location =
    > xlapp.ActiveSheet.Range("A272")
    > 'xlapp.ActiveSheet.HPageBreaks(4).Location =
    > xlapp.ActiveSheet.Range("A324")
    >
    > objWorkBook.save
    > Set objWorkBook = Nothing
    > xlapp.Quit
    > Set xlaPP= Nothing
    >
    > Tom- Thanks for all of your time and help. I tried replying to your
    > verizon account but it doesnt seem to be reaching you.
    Follow-ups should ALWAYS go to the group. Because of very low volume
    these days, I almost never check that mailbox anymore.

    I looked in Excel's VBA (macro) help and found that the HPageBreaks
    collection requires that they be ADDed, before they can be moved,
    something like this ...

    Dim xlapp
    Dim objWorkBook
    DIM XLWB
    Set xlapp = CreateObject("EXCEL.APPLICATION")
    Set objWorkBook = xlapp.Workbooks.Open("C:\test22.xls")
    Const xlLandScape = 2
    xlapp.visible = true
    With xlapp.ActiveSheet
    with .PageSetup
    .Orientation = xlLandScape
    .FitToPagesWide = 1
    .FitToPagesTall = 99
    .Zoom = False
    end with
    .ResetAllPageBreaks
    for i = 83 to 324 step 82
    .HPageBreaks.Add .Range("A" & i)
    next
    end with
    wsh.echo "Done"

    Once they have been created, the Location property can be used to move
    them. But, before they are added, there is no array - that's why you
    get the "out of range" error.
    _____________________
    Tom Lavedas

      My System SpecsSystem Spec

excel

Similar Threads
Thread Thread Starter Forum Replies Last Post
running Excel Macro in in specified Excel files in spe Observer PowerShell 0 03 Apr 2009
create Excel spreadsheet without loading Excel sneaky hamster VB Script 2 21 Oct 2008
Word&Excel:Add-Edit Toolbar&Buttons:Autocorrect to Excel Toolbar!! Wayne4Js Vista General 5 12 May 2008
How to view Excel document without Microsoft Office Excel installe jl Vista General 8 20 Apr 2008
Vista ASP.NET 2.0 Cannot open Excel File using Microsoft.Excel 12.0 COM object ckellywilson Microsoft Office 0 26 Mar 2008