none
Accessing MS Word Document Shapes collection RRS feed

  • Question

  • Hi All

    when accessing a documents shapes collection in word 2007 automation I get error 'Access is Denied' on the textframe attribute

    I am using VB 2010 with Interop.word 2007 DLL's

    e.g

    ---------------------------

    For each myshp as Microsoft.office.interop.word.shape in wd.shapes

    if myshp.TextFrame.HasText then 

    end if

    next

    ---------------------------------------------

    I get an 'Access Denied' error on the TextFrame property

    In word 2010 automation I DO NOT get the error

    Is the code correct for word 2007

    Friday, February 10, 2012 8:41 PM

Answers

  • What kind of Shape are you trying to use this on?

    Only Drawing objects (Shape.Type=msoAutoShape) can have text frames in Word 2007.

    Word 2007 implements even less of the new graphics engine introduced in Office 2007 than Word 2010 does. So code that works in, say, PowerPoint 2007 won't necessarily work in Word, nor code that works in Word 2010.

    You first need to test the type of Shape before you can query TextFrame.


    Cindy Meister, VSTO/Word MVP

    • Marked as answer by ga630sf Sunday, February 12, 2012 5:05 AM
    Saturday, February 11, 2012 5:41 PM
    Moderator

All replies

  • What kind of Shape are you trying to use this on?

    Only Drawing objects (Shape.Type=msoAutoShape) can have text frames in Word 2007.

    Word 2007 implements even less of the new graphics engine introduced in Office 2007 than Word 2010 does. So code that works in, say, PowerPoint 2007 won't necessarily work in Word, nor code that works in Word 2010.

    You first need to test the type of Shape before you can query TextFrame.


    Cindy Meister, VSTO/Word MVP

    • Marked as answer by ga630sf Sunday, February 12, 2012 5:05 AM
    Saturday, February 11, 2012 5:41 PM
    Moderator
  • Hi Cindy

    Thanks very much for the info

    I changed my code to check the shape.type and all works great now

    Regards

    Steve

    Sunday, February 12, 2012 5:06 AM