User (Legacy) Posted March 19, 2003 Report Share Posted March 19, 2003 Is there a way to reference the Annotations collection once they are imported on a chart using Import method? I am using VB6 and running ChartfX1.Import method to import a chart that has annotations in it. I then need to get a reference to those annotations collection so that I can add to them/remove them programmatically. ChartFX1.GetExtension method returns an error. Omitting the call causes a crash. Celia --------------------------------------------------- Sample Code: Option Explicit Private WithEvents CA As AnnotationX Private Sub cmdExport_Click(Index As Integer) ChartFX1.Export CHART_CFXOLEFILE, App.Path & "\Chart" & Index & ".chd" End Sub Private Sub cmdImport_Click(Index As Integer) ChartFX1.Import CHART_CFXOLEFILE, App.Path & "\Chart" & Index & ".chd" Set CA = Nothing End Sub Private Sub cmdRemoveAll_Click() If CA Is Nothing Then CA = ChartFX1.GetExtension("AnnotationX.AnnList") End If CA.Remove -1 ChartFX1.Refresh End Sub Private Sub Form_Load() If CA Is Nothing Then Set CA = New AnnotationX ChartFX1.AddExtension CA End If End Sub Private Sub Form_Unload(Cancel As Integer) If Not CA Is Nothing Then Set CA = Nothing End If End Sub Private Sub cmdAddAnn_Click() Dim r As AnnText If CA Is Nothing Then CA = ChartFX1.GetExtension("AnnotationX.AnnList") End If Set r = CA.Add(OBJECT_TYPE_TEXT) r.Top = 80 - (CA.Count * 10) r.Left = 100 r.Width = 100 r.Height = 40 r.Text = Now r.BorderStyle = LS_SOLID ChartFX1.Refresh End Sub Private Sub cmdCount_Click() If CA Is Nothing Then CA = ChartFX1.GetExtension("AnnotationX.AnnList") End If MsgBox "There are " & CA.Count & " annotations" End Sub Private Sub cmdMakeChanges_Click() ChartFX1.Gallery = AREA ChartFX1.Palette = "Dark Pastels" ChartFX1.ToolBar = False End Sub Link to comment Share on other sites More sharing options...
Software FX Posted March 24, 2003 Report Share Posted March 24, 2003 The following will do what you need: Dim CA As AnnotationX Set CA = ChartFX1.GetExtension("AnnotationX.AnnList") You must do an On Error statement if it is possible that the Annotation Extension is not attached to the chart when running this code. -- FP Software FX, Inc. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.