How to set the custome paper size in Excel Object through VB?

  
Showing Answers 1 - 1 of 1 Answers

Pallavi Baviskar

  • Jul 20th, 2006
 

    dim xlapp As Excel.Application
    dim xlbook As Excel.Workbook
    dim xlsheet As Excel.Worksheet
    dim xlPgSetup As Excel.PageSetup

    Set xlapp = New Excel.Application
    Set xlbook = xlapp.Workbooks.Open(App.Path & "try.xls") 'Open any  file here

    xlbook.Activate 
    DoEvents

    Set xlsheet = xlbook.Worksheets(1)    'Set any worksheet
    xlsheet.Activate

    Set xlPgSetup = xlsheet.PageSetup ' assign pagesetup of current sheet to xlPgSetup object
    xlPgSetup.PaperSize = xlPaperLetter 'Set the papersize here

    'xlPgSetup.PaperSize = xlPaperA4
    xlPgSetup.Orientation = xlLandscape

I am sure that there must be few more methods of doing the same job. Just u need to find all.

Pallavi Baviskar.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions