Consulting

Results 1 to 10 of 10

Thread: Shapes.AddDiagram

  1. #1
    VBAX Newbie
    Joined
    Nov 2007
    Posts
    2
    Location

    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?

  2. #2
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    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.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  3. #3
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    "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.

  4. #4
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  5. #5
    VBAX Newbie
    Joined
    Nov 2007
    Posts
    2
    Location
    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?

  6. #6
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    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.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  7. #7
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    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?

  8. #8
    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.

  9. #9
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    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.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  10. #10
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    "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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •