-
Shapes.AddDiagram
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?
-
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
[VBA] Selection.InlineShapes.AddOLEObject ClassType:="OrgPlusWOPX.4", FileName:= _
"", LinkToFile:=False, DisplayAsIcon:=False
[/VBA]
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.
-
"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.
-
-
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?
-
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.
-
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?
-
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.
-
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.
-
"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.