none
Create string variable with the filepath for template.crtx files and use in ActiveChart.ApplyChartTemplate(filepath template.crtx) RRS feed

  • Question

  • I am using the VBA code to make charts.

    I would like to create a variable for the path to the templates, in the event I change machines.

    i.e. Currently this works for applying 'red_template.crtx' to 'Chart_Great'

    ActiveSheet.ChartObjects("Chart_Great").Activate
            ActiveChart.ApplyChartTemplate ( _
                "C:\Users\joe\AppData\Roaming\Microsoft\Templates\Charts\red_template.crtx" _
                )

    I would like to change the above working example to:

    Dim TemPath As String
    TemPath = "C:\Users\joe\AppData\Roaming\Microsoft\Templates\Charts\"

    ActiveSheet.ChartObjects("Chart_Great").Activate
            ActiveChart.ApplyChartTemplate ( _
                "TemPath & red_template.crtx" _
                )

    I am new to VBA and by no means a programmer, so any elementary help is welcomed.

    Thanks for your time.

    Thursday, July 21, 2016 7:31 PM

Answers