ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   User-defined chart type deployment (https://www.excelbanter.com/excel-programming/296769-user-defined-chart-type-deployment.html)

Jeff K[_2_]

User-defined chart type deployment
 
In Excel 2002, under XP professional, I have an application that uses custom chart types (User-defined) stored in the xlusrgal.xls file. I would like the application to use this file, but I do not want to overwrite any existing custom chart types. I want the application to use my xlusrgal only when the application needs it and leave any other xlusrgal file alone. In prior versions of Excel, I was able to accomplish by setting/resetting the alt startup path after program initiation and storing the xlusrgal file there. This does not seem to work anymore. Any workarounds? (Thanks in advance.)

Jon Peltier[_7_]

User-defined chart type deployment
 
Jeff -

Here's how to distribute those custom chart types.

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 the 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
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Jeff K wrote:

In Excel 2002, under XP professional, I have an application that uses
custom chart types (User-defined) stored in the xlusrgal.xls file. I
would like the application to use this file, but I do not want to
overwrite any existing custom chart types. I want the application to
use my xlusrgal only when the application needs it and leave any
other xlusrgal file alone. In prior versions of Excel, I was able to
accomplish by setting/resetting the alt startup path after program
initiation and storing the xlusrgal file there. This does not seem
to work anymore. Any workarounds? (Thanks in advance.)




All times are GMT +1. The time now is 06:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com