ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert Diagram (https://www.excelbanter.com/excel-programming/363543-insert-diagram.html)

Gary''s Student

Insert Diagram
 
How can I get

Insert Diagram

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

Tom Ogilvy

Insert Diagram
 
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


Gary''s Student

Insert Diagram
 
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


Tom Ogilvy

Insert Diagram
 
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


Gary''s Student

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



All times are GMT +1. The time now is 09:55 PM.

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