Results 1 to 4 of 4

Thread: Using Excel in VB .NET

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2003
    Posts
    31

    Question Using Excel in VB .NET

    Well most of the excel code for excel 9.0 object library works in .NET correctly.....but I have one question.

    When I create a excel application object, how do I get VB . NET to change the orientation of the worksheet to landscape instead of portrait?

    I used the following code in VB 6.0 but it doesn't work in .NET.

    oExcelApp.ActiveSheet.PageSetup.Orientation = xlPortrait

    It doesn't recognize the xlportrait part of the equation.

    Any help would be appreciated.

  2. #2
    Member
    Join Date
    Sep 2002
    Posts
    37
    Hi

    I had a similar problem. You can use the Enum values to get around it for now . Just replace the constants with their values in your code. The values can be found in the Object Browser.

    oExcelApp.ActiveSheet.PageSetup.Orientation = 1

    xlPortait = 1
    xlLandscape = 2

    If you find a better solution please post it.

    Harold Hoffman

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2003
    Posts
    31
    Thanks for the help....there is another way also

    oWs = oExcelApp.ActiveSheet
    oWs.PageSetup.Orientation = Excel.XlPageOrientation.xlPortrait


    This will work as well

  4. #4
    Member
    Join Date
    Sep 2002
    Posts
    37
    Hi

    Your way is better and works fine. Little difficult though to find the right object model.

    Thanks.

Posting Permissions

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



Click Here to Expand Forum to Full Width