Thread: Insert Diagram
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Insert Diagram

Thank you very much Tom.


The sub works perfectly. I'll now work on figuring out how to enter text.
This is a major help to me since my original approach was to embed Visio
objects; that approach falls flat on its face when tried on computers not
having Visio.
--
Gary''s Student


"Tom Ogilvy" wrote:

Sub AddPyramid()
Dim obj As Shape
With Range("B5:J25")
Set obj = ActiveSheet.Shapes.AddDiagram( _
Type:=msoDiagramPyramid, _
Top:=.Top, _
Left:=.Left, _
Width:=.Width, _
Height:=.Height)
Set nd = obj.DiagramNode.Children.AddNode
End With
For i = 1 To 2
nd.AddNode
Next
End Sub


adds the pyramid. I think you will have to play around with the object
model for these to figure out how to get the basic "node" for each type
(beyond changing the type property). Also, I believe these were added in
xl2003, so not available in earlier versions.

--
Regards,
Tom Ogilvy


"Gary''s Student" wrote:

Thank you Tom,

I am just trying to insert one of the pre-canned diagrams via VBA.
--
Gary''s Student


"Tom Ogilvy" wrote:

I doubt there is a way.
Are you just trying to discover the objects associated with that activity?

the shapes collection has an adddiagram method.
--
Regards,
Tom Ogilvy


"Gary''s Student" wrote:

How can I get

Insert Diagram

to function when the Macro Recorder is turned on?
--
Gary's Student