How to change an excel chart axis text orientation in VB.Net?
Hi, I am developing a VB.Net application that will populate data from database to excel and create an excel chart base on the data. I already got excel data and chart, but I need to change one axis text orientation to 45 degree. How can I do that in VB code? Thanks for the help!
Last edited by mrtxu; September 22nd, 2003 at 10:59 AM.
Sorry, with statement should begin with the Activechart line. For example if your active chart is named xlchart
By the way, go to Excel, turn macro tool on, and record the macro as you rotate the axis label on the chart. After rotation is complete, stop recording macro. Then edit macro to see the visual basic code created. You can bring this code into VB.Net with minor variations with respect to the object names: Excel sheet name, chart name, etc. For any Excel command/function that you want to implement in VB, this is a good way to find the syntax.
Sorry to bother again Gizmo001! My VB.Net won't recognize Axes(xlCategory) saying xlCategory not defined. And also ActiveChart, ActiveSheet, etc. I am thinking maybe I need to import some special classes. But I can get regular chart on the sheet already. I am so confused. Since the X axis label is now showing horizontally its not showing all on the chart when taking larger numbers of rows from excel. That's the reason I want to change its orientation to 45 degree or 90 degree. Although I can manually change that in excel I still think there should be a way in VB.Net coding.
Sorry, I tried to check it out, and it didn't work either. It used to work with earlier verisions of Excel reference library (8.0 Object library), but with 10.0, it does not work. I have not been able to figure out the equivalent syntax for the new Excel library.