Home > Community > Automation and VBA > Copying markers from a diagram to a document > Antwort auf: Copying markers from a diagram to a document

#12446
Krista TweedKrista Tweed
Mitglied

I am writting a VBA application that needs to copy the Markers text from a 2D-Diagram to the 2D-Diagram included in a Document.

I have a 2D-Diagram with two curves and a Document which contains a copy of the 2D-Diagram. I set several markers in the 2D-Diagram and then I run my macro to copy only some of the markers into the document.

The macro is able to copy the markers with X and Y coordinates but is unable to change the text of the marker.

Here is a part of the macro :
——————————————
Dim Diagramme As Diagram2D
Dim Doc As Document
Dim NbMarkers As Integer

‘Activate 2D-Diagram object
ActiveDatabase.RootFolder.Object (“2D-Diagram.2D”)
Set Diagramme = ActiveDatabase.ActiveObject

‘get NbMarkers in the 2D-Diagram object
NbMarkers = ActiveDatabase.ActiveObject.Markers.Count

‘Activate the Document Object
Windows(“CalculsDocument (Document)”).Activate

‘Activate the 2D-Diagram object in the document
ActiveDatabase.ActiveObject.Pages(1).Item(1).Select

Set Doc = ActiveDatabase.ActiveObject

‘Active cursors
Doc.CursorActive = True

‘Autocenter Off
Doc.ActiveCursor.Bounded = False

‘Place cursorX and cursorY in the document
Doc.ActiveCursor.PositionX = TabMarker(i, 0)
Doc.ActiveCursor.PositionY = TabMarker(i, 1)

‘Place marker in the document
Doc.ActiveCursor.PlaceMarker

‘Change the marker text
ActiveDatabase.ActiveObject.Markers.Item(1).Text=”O1″

—————————————————————————-

The last line ActiveDatabase.ActiveObject.Markers.Item(1).Text=”O1″ changes the marker text in the “2D-Diagram” but not in the document .

Is it possible to change the text of the markers only in the document and not in the original 2D-Diagram ?