PDA

View Full Version : Shapes.AddDiagram



14bucko
11-07-2007, 08:32 PM
I have an automated organisational chart that works in Office 2003 but fails in Office 2007 on the following line:

Set shpDiagram = ActiveDocument.Shapes.AddDiagram(Type:=msoDiagramOrgChart, Left:=10, Top:=15, Width:=400, Height:=475)

Runtime error 445: Object doesn't support this action.

MSDN shows an example of this code in use in the 2007 object model, and Word help references the same code but the sample does not work.

The forum wont allow me to post a link but searching for XMLNode.FirstChild in msdn or help brings up the sample code.

Whats going on here?

TonyJollans
11-08-2007, 03:37 AM
I always take Microsoft documentation and Help with a large pinch of salt. This is clearly a hangover from old versions.

If you want this in Word 2007, you can record the insertion to get code - which gives this
Selection.InlineShapes.AddOLEObject ClassType:="OrgPlusWOPX.4", FileName:= _
"", LinkToFile:=False, DisplayAsIcon:=False


or you can use the new Smart Art version - but recording that doesn't give you any code and I don't at the moment know how to code it myself.

fumei
11-10-2007, 10:48 PM
"don't at the moment know how to code it myself."

Gasp, he is human after all. You have no idea how relieved I am to know that.

TonyJollans
11-11-2007, 02:02 AM
:rotlaugh:

14bucko
11-11-2007, 04:34 PM
Hey Tony,

Your example loads the organisational chart add-in, not the diagram object. Can the add-in be programmed?

Smart Art does not have an object model so thats pointless.

Anybody else have any ideas?

TonyJollans
11-11-2007, 05:40 PM
You are correct. I hadn't paid much attention to what it was doing. I just recorded it and pasted the code. Sorry, and, no, as far as I know it can't be programmed.

There seems to be quite a lot that can't be done in VBA in 2007, and I think you've stumbled over some of it.

fumei
11-11-2007, 08:21 PM
I have not really used 2007 (other than playing a bit with the Beta), but I am starting to really dislike it.

Why are they doing this? Taking out Filesearch for example (a very handy functionality), and making so much unexposed to VBA. I don't get it.

Did they not get the most massive amount of product beta testing EVER? Was not anyone paying attention?

Is not VBA supposed to give developers as much of the application to work with as can be done?

Sheeesh. What am I talking about?

Nelviticus
11-12-2007, 03:05 AM
I think they're trying to get people to move over to using Visual Studio with the Tools For Office add-in (which will be integrated into the new version due out this month). From what I've read VBA will stick around but will only be expected to do fairly simple stuff with Visual Studio being used for anything fancy.

Why, I have no idea. As someone who has to support a bunch of code-filled templates which are about to be migrated to Office 2007 I'm not overly chuffed about it!

If enough people moan about it I expect that Microsoft will eventually change their minds. Personally I think that if Word can do it VBA should be able to automate it.

TonyJollans
11-12-2007, 03:39 AM
I agree they seem to be trying to make code the province of the developer rather than the casual user - bowing to pressure from corporates and removing facilities from users. Personally, I think this is a bit short sighted.

fumei
11-12-2007, 11:08 AM
"I agree they seem to be trying to make code the province of the developer rather than the casual user - bowing to pressure from corporates and removing facilities from users."

Aaaahhhhh. I had never thought of that. Yes, I suppose that is exactly why.

Not surprising actually. Certainly within our environment that is most definitely the view.