+ Reply to Thread
Results 1 to 4 of 4

How do I select multiple worksheets for print preview?

  1. #1
    steve
    Guest

    How do I select multiple worksheets for print preview?

    In VBA one can select multiple worksheets by passing an array. How is this
    same thing accomplished using C#?

    I would like to select a number of worksheet from the entire workbook for a
    print preview. Thus having only the selected worksheets appear in the
    preview.
    The following shows the entire workbook.

    objExcel.Worksheets.PrintPreview(Missing.Value);

    Steve


  2. #2
    Tom Ogilvy
    Guest

    Re: How do I select multiple worksheets for print preview?

    You would have to select the sheets, but then

    objExcel.Activewindow.SelectedSheets.PrintPreview(Missing.Value);

    I would think.

    --
    Regards,
    Tom Ogilvy

    "steve" <[email protected]> wrote in message
    news:[email protected]...
    > In VBA one can select multiple worksheets by passing an array. How is

    this
    > same thing accomplished using C#?
    >
    > I would like to select a number of worksheet from the entire workbook for

    a
    > print preview. Thus having only the selected worksheets appear in the
    > preview.
    > The following shows the entire workbook.
    >
    > objExcel.Worksheets.PrintPreview(Missing.Value);
    >
    > Steve
    >




  3. #3
    steve
    Guest

    Re: How do I select multiple worksheets for print preview?

    Thank you for your reponse. It was helpful in printing one selected sheet.
    However, I do not know how to programmaticaly select multiple sheets. Also,
    I am using Excel 2000.

    I have tried:

    string[] stuff = {"Raw Data", "Inventory"};
    objSheets.get_Item(stuff);
    objExcel.ActiveWindow.SelectedSheets.PrintPreview(Missing.Value);

    or

    string[] stuff = {"Raw Data", "Inventory"};
    objSheets.Select(stuff);
    objExcel.ActiveWindow.SelectedSheets.PrintPreview(Missing.Value);

    But the PrintPreview command throws an error in each case. PrintPreview was
    tried on the Workbook and WorkSheets objects also.

    also manually selecting each sheet doesn't work either

    (Excel.Worksheet)objExcel.Sheets[2]).Select(Missing.Value);
    (Excel.Worksheet)objExcel.Sheets[5]).Select(Missing.Value);
    objExcel.ActiveWindow.SelectedSheets.PrintPreview(Missing.Value);

    Any ideas?

    Thank you

    Steve


    "Tom Ogilvy" wrote:

    > You would have to select the sheets, but then
    >
    > objExcel.Activewindow.SelectedSheets.PrintPreview(Missing.Value);
    >
    > I would think.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "steve" <[email protected]> wrote in message
    > news:[email protected]...
    > > In VBA one can select multiple worksheets by passing an array. How is

    > this
    > > same thing accomplished using C#?
    > >
    > > I would like to select a number of worksheet from the entire workbook for

    > a
    > > print preview. Thus having only the selected worksheets appear in the
    > > preview.
    > > The following shows the entire workbook.
    > >
    > > objExcel.Worksheets.PrintPreview(Missing.Value);
    > >
    > > Steve
    > >

    >
    >
    >


  4. #4
    Tom Ogilvy
    Guest

    Re: How do I select multiple worksheets for print preview?

    Select takes an optional argument when used with worksheets.

    Select the first worksheet as you normally would

    then select each of the remainder with an argument of False

    The false says not to replace the currently selected sheet, but to add the
    referenced sheet to the selected sheets.

    you also might try

    objSheets(stuff).PrintPreview

    (obviously the C# equivalent - I don't know anything about C#).

    --
    Regards,
    Tom Ogilvy

    "steve" <[email protected]> wrote in message
    news:[email protected]...
    > Thank you for your reponse. It was helpful in printing one selected sheet.
    > However, I do not know how to programmaticaly select multiple sheets.

    Also,
    > I am using Excel 2000.
    >
    > I have tried:
    >
    > string[] stuff = {"Raw Data", "Inventory"};
    > objSheets.get_Item(stuff);
    > objExcel.ActiveWindow.SelectedSheets.PrintPreview(Missing.Value);
    >
    > or
    >
    > string[] stuff = {"Raw Data", "Inventory"};
    > objSheets.Select(stuff);
    > objExcel.ActiveWindow.SelectedSheets.PrintPreview(Missing.Value);
    >
    > But the PrintPreview command throws an error in each case. PrintPreview

    was
    > tried on the Workbook and WorkSheets objects also.
    >
    > also manually selecting each sheet doesn't work either
    >
    > (Excel.Worksheet)objExcel.Sheets[2]).Select(Missing.Value);
    > (Excel.Worksheet)objExcel.Sheets[5]).Select(Missing.Value);
    > objExcel.ActiveWindow.SelectedSheets.PrintPreview(Missing.Value);
    >
    > Any ideas?
    >
    > Thank you
    >
    > Steve
    >
    >
    > "Tom Ogilvy" wrote:
    >
    > > You would have to select the sheets, but then
    > >
    > > objExcel.Activewindow.SelectedSheets.PrintPreview(Missing.Value);
    > >
    > > I would think.
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > > "steve" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > In VBA one can select multiple worksheets by passing an array. How is

    > > this
    > > > same thing accomplished using C#?
    > > >
    > > > I would like to select a number of worksheet from the entire workbook

    for
    > > a
    > > > print preview. Thus having only the selected worksheets appear in the
    > > > preview.
    > > > The following shows the entire workbook.
    > > >
    > > > objExcel.Worksheets.PrintPreview(Missing.Value);
    > > >
    > > > Steve
    > > >

    > >
    > >
    > >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1