How to: Retrieving BuiltinDocumentProperties from Word Document

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Charles Law

    How to: Retrieving BuiltinDocumentProperties from Word Document

    Word has a property BuiltinDocument Properties, which (in VBA) returns a
    DocumentPropert ies collection. In VB.NET, using Word automation, it returns
    a _ComObject. I have tried to cast this to DocumentPropert ies, but I get an
    invalid cast exception.

    In Explorer, I can right click a Word document, click Properties, and I get
    a tabbed dialog with Custom and Summary tabs. These tabs show me the built
    in document properties of the document.

    I notice that Explorer does this without starting a copy of Word, and it
    does it reasonably quickly. The only coded example I have found uses late
    binding to retrieve a property by name, but it assumes that I know the name
    of the properties in advance.

    How can I get at these properties in the same way that Explorer does it,
    without starting Word? Also, Explorer can get the properties of a PDF,
    without starting Acrobat, so there must be a generic way.

    Failing that, how can I use Word automation and early binding to get them?

    Any thoughts?

    TIA

    Charles


  • Paul Clement

    #2
    Re: How to: Retrieving BuiltinDocument Properties from Word Document

    On Sat, 28 Jan 2006 09:23:49 -0000, "Charles Law" <blank@nowhere. com> wrote:

    ¤ Word has a property BuiltinDocument Properties, which (in VBA) returns a
    ¤ DocumentPropert ies collection. In VB.NET, using Word automation, it returns
    ¤ a _ComObject. I have tried to cast this to DocumentPropert ies, but I get an
    ¤ invalid cast exception.
    ¤
    ¤ In Explorer, I can right click a Word document, click Properties, and I get
    ¤ a tabbed dialog with Custom and Summary tabs. These tabs show me the built
    ¤ in document properties of the document.
    ¤
    ¤ I notice that Explorer does this without starting a copy of Word, and it
    ¤ does it reasonably quickly. The only coded example I have found uses late
    ¤ binding to retrieve a property by name, but it assumes that I know the name
    ¤ of the properties in advance.
    ¤
    ¤ How can I get at these properties in the same way that Explorer does it,
    ¤ without starting Word? Also, Explorer can get the properties of a PDF,
    ¤ without starting Acrobat, so there must be a generic way.
    ¤
    ¤ Failing that, how can I use Word automation and early binding to get them?

    See if the following helps:

    How To Use Automation to Get and to Set Office Document Properties with Visual Basic .NET



    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

    Comment

    • Charles Law

      #3
      Re: How to: Retrieving BuiltinDocument Properties from Word Document

      Hi Paul

      Thanks for the reply. It's actually this article that I am using as my
      starting point.

      In the article, Word is launched and a /known/ parameter - Author - is read.
      Everything is done using late binding, and I would like to use early binding
      because I always have Option Strict On.

      Also, it presupposes that I know which properties I want to read, when, in
      fact, I just want to get a list of the existing ones (and any custom
      properties) to display to the user.

      Thirdly, it is very slow, having to launch Word just to read these
      properties. It would be nice to know how Explorer can do it so much more
      quickly.

      Charles


      "Paul Clement" <UseAdddressAtE ndofMessage@sws pectrum.com> wrote in message
      news:1hcst1pta7 17hakkl5t7n2rbr u3smru2da@4ax.c om...[color=blue]
      > On Sat, 28 Jan 2006 09:23:49 -0000, "Charles Law" <blank@nowhere. com>
      > wrote:
      >
      > ¤ Word has a property BuiltinDocument Properties, which (in VBA) returns a
      > ¤ DocumentPropert ies collection. In VB.NET, using Word automation, it
      > returns
      > ¤ a _ComObject. I have tried to cast this to DocumentPropert ies, but I get
      > an
      > ¤ invalid cast exception.
      > ¤
      > ¤ In Explorer, I can right click a Word document, click Properties, and I
      > get
      > ¤ a tabbed dialog with Custom and Summary tabs. These tabs show me the
      > built
      > ¤ in document properties of the document.
      > ¤
      > ¤ I notice that Explorer does this without starting a copy of Word, and it
      > ¤ does it reasonably quickly. The only coded example I have found uses
      > late
      > ¤ binding to retrieve a property by name, but it assumes that I know the
      > name
      > ¤ of the properties in advance.
      > ¤
      > ¤ How can I get at these properties in the same way that Explorer does it,
      > ¤ without starting Word? Also, Explorer can get the properties of a PDF,
      > ¤ without starting Acrobat, so there must be a generic way.
      > ¤
      > ¤ Failing that, how can I use Word automation and early binding to get
      > them?
      >
      > See if the following helps:
      >
      > How To Use Automation to Get and to Set Office Document Properties with
      > Visual Basic .NET
      > http://support.microsoft.com/default...b;en-us;303294
      >
      >
      > Paul
      > ~~~~
      > Microsoft MVP (Visual Basic)[/color]


      Comment

      • Charles Law

        #4
        Re: How to: Retrieving BuiltinDocument Properties from Word Document

        For anyone wondering how this is done, the answer is IPropertyStorag e.

        The following link leads to an article and ActiveX control that does the
        job:

        Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows, Surface, and more.


        Charles


        "Charles Law" <blank@nowhere. com> wrote in message
        news:%23sxsNy%2 3IGHA.516@TK2MS FTNGP15.phx.gbl ...[color=blue]
        > Word has a property BuiltinDocument Properties, which (in VBA) returns a
        > DocumentPropert ies collection. In VB.NET, using Word automation, it
        > returns a _ComObject. I have tried to cast this to DocumentPropert ies, but
        > I get an invalid cast exception.
        >
        > In Explorer, I can right click a Word document, click Properties, and I
        > get a tabbed dialog with Custom and Summary tabs. These tabs show me the
        > built in document properties of the document.
        >
        > I notice that Explorer does this without starting a copy of Word, and it
        > does it reasonably quickly. The only coded example I have found uses late
        > binding to retrieve a property by name, but it assumes that I know the
        > name of the properties in advance.
        >
        > How can I get at these properties in the same way that Explorer does it,
        > without starting Word? Also, Explorer can get the properties of a PDF,
        > without starting Acrobat, so there must be a generic way.
        >
        > Failing that, how can I use Word automation and early binding to get them?
        >
        > Any thoughts?
        >
        > TIA
        >
        > Charles
        >
        >[/color]


        Comment

        Working...