Guten Tag,
Ich habe ein VBA-Problem. Und zwar lasse ich mir mit folgenden Code (s.u.) ein Organigramm generieren. Das funktioniert auch, allerdings nur bis Office 2003. Ab Office 2007 bekomme ich die Fehlermeldung „Object doesn’t support this action“ bei der Zeile
Set oCurShape = oCurWorkApplObj.ActiveDocument.Shapes.AddDiagram _
Kann mir da jemand weiterhelfen?
Viele Grüsse,
Nick
Sub TextShapeAddText()
'/ Dim Integer(s)
Dim i As Integer
'/ Dim Object(s)
Dim oCurShape As Object
Dim oCurShapeNode As Object
Dim oCurDiagNode As Object
Dim oCurWorkApplObj As Object
'/ Create a Word application object.
Set oCurWorkApplObj = CreateObject(„Word.Application“)
'/ Open a new Word document.
Workbooks.Add
oCurWorkApplObj.Documents.Add
'/ Add a shape.
Set oCurShape = oCurWorkApplObj.ActiveDocument.Shapes.AddDiagram _
(msoDiagramOrgChart, 10, 15, 400, 475)
'/ Add a node.
Set oCurShapeNode = oCurShape.DiagramNode.Children.AddNode
'ActiveSheet.Shapes(1).Diagram.Nodes(1).TextShape.Fill.BackColor.SchemeColor = 17
'/ Add child nodes.
For i = 1 To 3
oCurShapeNode.AddNode
Next
'/ Add text to the child nodes.
For i = 1 To 4 'Inserting text in each node
oCurShapeNode.Diagram.Nodes.Item(i) _
.TextShape.TextFrame.TextRange.Text = Str(i)
Next
'/ Copy the shape to Excel.
oCurWorkApplObj.ActiveDocument.Shapes.SelectAll
oCurWorkApplObj.Selection.Copy
ActiveSheet.Paste
'/ Quit Word.
oCurWorkApplObj.Quit saveChanges:=False
End Sub