none
Property is NULL in Automation? RRS feed

  • Question

  • Hi,

     

    I am using Visual C++ 2008 together to automate Word 2010. Visual C++ just wraps the interface in Word 2010 and generate a lot of classes derived from COleDispatchDriver, like this:

     

    class COLEStyle : public COleDispatchDriver

     

    {

     

     

    }

     

    So I can get the properties of an object by calling the functions in the wrapped class, for example:

     

        LPDISPATCH get_ListTemplate()

        {

            LPDISPATCH result;

            InvokeHelper(0xe, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL);

            return result;

    }

     

    In one of my call to get_ListTemplate, as follows:

     

    OLENewStyle.get_ListTemplate();

     

    The function returns NULL? What does this mean? Does that mean my OLENewStyle object does not has such a property or the property exists but is just NULL?

     

    Thanks

    Saturday, December 5, 2015 6:53 AM

Answers

  • Style object I understand :-)

    In a quick test (VBA) it appears that, if no ListTemplate is associated with the style, the object model says "no such member available for the object". That's not the actual error message, but in essence that's what it means in this case. So:

    "OLENewStyle object does not has such a property"

    when no ListTemplate is linked to the paragraph style. When a ListTemplate is linked to a paragraph style then the property returns that object.


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    • Marked as answer by tempc Saturday, January 26, 2019 3:20 AM
    Wednesday, December 9, 2015 6:22 PM
    Moderator
  • That's how it looks to me, yes, at least for this particular scenario.

    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    • Marked as answer by tempc Saturday, January 26, 2019 3:20 AM
    Thursday, December 10, 2015 5:34 PM
    Moderator

All replies

  • What's OLENewStyle?


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Monday, December 7, 2015 6:09 PM
    Moderator
  • What's OLENewStyle?


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    OLENewStyle is an instance of COLEStyle class. COLEStyle class is the wrapper class for Style object(in Word automation object model) generated by TypeLib Wizard for the TypeLib of Word.

    Below is the reference for the property:

    https://msdn.microsoft.com/en-us/library/office/ff840860.aspx

    Tuesday, December 8, 2015 6:50 AM
  • Style object I understand :-)

    In a quick test (VBA) it appears that, if no ListTemplate is associated with the style, the object model says "no such member available for the object". That's not the actual error message, but in essence that's what it means in this case. So:

    "OLENewStyle object does not has such a property"

    when no ListTemplate is linked to the paragraph style. When a ListTemplate is linked to a paragraph style then the property returns that object.


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    • Marked as answer by tempc Saturday, January 26, 2019 3:20 AM
    Wednesday, December 9, 2015 6:22 PM
    Moderator
  • Style object I understand :-)

    In a quick test (VBA) it appears that, if no ListTemplate is associated with the style, the object model says "no such member available for the object". That's not the actual error message, but in essence that's what it means in this case. So:

    "OLENewStyle object does not has such a property"

    when no ListTemplate is linked to the paragraph style. When a ListTemplate is linked to a paragraph style then the property returns that object.


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Thank you so much. So returning a NULL is not an error, but just indication of "OLENewStyle object does not has such a property". Is that correct?

    Wednesday, December 9, 2015 11:34 PM
  • That's how it looks to me, yes, at least for this particular scenario.

    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    • Marked as answer by tempc Saturday, January 26, 2019 3:20 AM
    Thursday, December 10, 2015 5:34 PM
    Moderator
  • Hi, Cindy,

    Thank you very much.

    Saturday, January 26, 2019 3:20 AM