Custom chart use on another machine

  • Thread starter Thread starter Patrick
  • Start date Start date
P

Patrick

Hello,

I have created several user-defined chart "templates" for
the purpose of having a macro use these charts to present
data that is being pulled in from a text file. Everything
works fine on my computer, but when the same workbook
emailed to another computer and launched, the macro that
is responsible for generating instances of my user-defined
charts, fails because it does not recognize the user-
defined chart types. Sure enough, when I looked at the
available chart types, the user-defined charts that I
created were not there. Does anyone know why these user-
defined charts are not available on the other machine but
they are on mine? Thanks in advance.
 
Patrick -

Here's what you do. Embed each custom chart template on its own
worksheet. Put the name for this chart type in cell A1 of the sheet,
and the description in cell A2.

Put this macro into a regular code module in the workbook containing
your custom chart templates:

Sub DistributeChartTypes()
Dim ws As Worksheet
Dim cht As Chart
Dim chto As ChartObject
For Each ws In ActiveWorkbook.Worksheets
If ws.ChartObjects.Count > 0 Then
If Len(ws.Cells(1, 1).Value) > 1 Then
Set cht = ws.ChartObjects(1).Chart
Application.AddChartAutoFormat Chart:=cht, _
Name:=ws.Cells(1, 1).Value, _
Description:=ws.Cells(2, 1)
End If
End If
Next
End Sub

Finally, put this macro into the "ThisWorkbook" code module of the
workbook with teh custom charts:

Private Sub Workbook_Open()
DistributeChartTypes
End Sub

Send out the file with instructions to open it with macros enabled. The
Workbook_Open procedure will run when the workbook opens, which runs the
DistributeChartTypes procedure. If any chart types with the same name
is present, the new one will overwrite the existing one.

- Jon
 
Back
Top