10 Replies Latest reply: Jun 9, 2011 11:25 AM by gaetan_frenoy RSS

    How to add a calculated dimension to a chart from a VBScript macro ?

      Hi all,


      I need to create a bunch of graphs and wanted to quickly write a little macro that would replicate the same layout for all the required graphs.


      So I started to write some lines of code but quickly hit a problem.  Here is the (simplified) code:

      Function CreateGraphs()
        Set chart = ActiveDocument.ActiveSheet.CreateLineChart
        chart.AddDimension "=IF([DeterminationCode]='XYZ', [SamplingTime])"
        chart.AddExpression "MeasurementValue"
      End Function


      For some reason, this line "chart.AddDimension" is silently ignored.  If I add the same calculated dimension interactively: no problem, all is working perfectly.  But I'm unable to reach the same result via the macro.


      It looks like this issue has already been raised in a previous post but I could find the right way to workaround the issue.


      Any suggestion to help me?


      Thanks a lot, have a great day.