Advertisement

05.16.2008 at 11:31AM PDT, ID: 23409319
[x]
Attachment Details

How to change the page setup for the current object being printed

Asked by Mafalda in Microsoft Visual Basic.Net

Tags: , , ,

I use the following code to print Excel Sheets on the active printer.
Printout is done fine with default printer settings.
I need a way to change the settings for the page being printed in several cases.
e.g. I need one page to be printed in landscape.
I need to know how can I control the page setup before I print.

Imports Excel

Private Sub PrintActions()
    Dim xlApp As Global.Excel.Application
    Dim xlWkb As Global.Excel.Workbook

     xlApp = CreateObject("Excel.Application")

    xlWkb = xlApp.Workbooks.Open("c:\myfile.xls")

    With xlWkb
        .Sheets("Sheet3").Select()
        .ActiveSheet.PrintOut()
      End With

      xlWkb.Close()
      xlApp.Quit()

End Sub
Start Free Trial
 
 
[+][-]05.16.2008 at 01:16PM PDT, ID: 21586087

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: Microsoft, VB.NET, 2005, Excel
Sign Up Now!
Solution Provided By: maatthias
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.16.2008 at 11:54PM PDT, ID: 21588217

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628