GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Programming  >  VBA

 Print  |  
Question:  How to set the custome paper size in Excel Object through VB?



July 07, 2006 07:59:53 #1
 Pallavi Baviskar   Member Since: Visitor    Total Comments: N/A 

RE: How to set the custome paper size in Excel Object ...
 

    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.

     

 

Back To Question