-
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. :)
-
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
-
Thanks for the help....there is another way also
oWs = oExcelApp.ActiveSheet
oWs.PageSetup.Orientation = Excel.XlPageOrientation.xlPortrait
This will work as well :)
-
Hi
Your way is better and works fine. Little difficult though to find the right object model.
Thanks.