VB.net code do the simple operation of twitching "Axis Type" from automatic to "Date axis".

I've got some code which populates events over time on an excel sheet. At the end of the process my program creates a chart using the following code

Imports Excel = Microsoft.Office.Interop.Excel

 Dim xlApp As Excel.Application = New Microsoft.Office.Interop.Excel.Application()
    Dim xlWorkBook As Excel.Workbook = Nothing
    Dim xlWorkbooks As Excel.Workbooks = Nothing
    Dim xlWorkSheet As Excel.Worksheet = Nothing

    Dim chartPage As Excel.Chart
    Dim xlCharts As Excel.ChartObjects
    Dim myChart As Excel.ChartObject
    Dim chartRange As Excel.Range

xlCharts = xlWorkSheet.ChartObjects
        myChart = xlCharts.Add(10, 80, 900, 500)
        chartPage = myChart.Chart
        chartRange = xlWorkSheet.Range("B1", "d100")
        chartPage.SetSourceData(Source:=chartRange)
        chartPage.ChartType = Excel.XlChartType.xlBarStacked

How do I, in VB.net code do the simple operation of twitching "Axis Type" from automatic to "Date axis". This is usually found by clicking the vertical axis of a chart, format axis, axis options - date axis.

Is there a resource to find these commands?

Best regards,

Sean
Sean KilburnAsked:
Who is Participating?
 
Rgonzo1971Commented:
Hi,

pls try something like this
With chartPage.Axes(Excel.XlAxisType.xlCategory)
     .categorytype = Excel.XlCategoryType.xlTimeScale
     .BaseUnit = Excel.XlTimeUnit.xlDays
End With

Open in new window

Regards
0
 
Sean KilburnAuthor Commented:
Absolute legend. Worked straight away!!

Just as a side question, is there a resource you use to find these commands?

Thanks again for your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.