Ingres Community Forums Login Register Ingres.com  

Ingres Community Forum


Go Back   Ingres Community Forums > Ingres Forums > OpenROAD Developer's Forum
 

Reply
 
LinkBack (1) Thread Tools Display Modes
Old 2009-12-03   1 links from elsewhere to this Post. Click to view. #1 (permalink)
Ingres Community
 
Join Date: May 2007
Posts: 52
Default Word / Office ActiveX - Document Properties

I wish to access the DocumentProperties attribute of a Word document, which I should be able to via BuiltInDocumentProperties or CustomDocuemntProperties on the main Document class, however ..

Looking at the class browser for my Word External Class, both methods/attributes are defined as returning a _document type, when it should be DocumentProperties ....

Further more my Office 11 External Class cannot even see the DocumentProperties and DocumenProperty attributes which I know exist!

Shall I raise both these as in issue?
Pete.Wilkinson@vivista.sungard.com is offline   Reply With Quote
Old 2009-12-03   #2 (permalink)
Ingres Corp
 
Join Date: Mar 2007
Location: On the OpenROAD
Posts: 828
Default

Looking at the type library (using OleView) both BuiltInDocumentProperties and CustomDocuemntProperties properties for the interface _Document (which the Document class implements) are defined of type "IDispatch*", which means "some COM object" - not "DocumentProperties" as you wrote.
In the OpenROAD class browser such types are shown with the name of the interface itself rather than just as ExternalObject or "IDispatch", but this is rather a nuisance.

In addition I can't find "DocumentProperties" and "DocumentProperty" attributes in the type library, which means that they don't exist (so OpenROAD is right about this).
Where do you get the information about their existence from?
Bodo is offline   Reply With Quote
Old 2009-12-04   #3 (permalink)
Ingres Community
 
Join Date: May 2007
Posts: 52
Default

As I cannot get OLEViewer to work I cannot confirm what you say, and my knowledge only comes from what I can gleem from some other TypeLibrary Viewer I use, Microsoft documentation and of course Google! Plus looking at the VBA (that comes with Word) Object Browser DocumentProperties is there, honest

DocumentProperties Collection Object

BuiltInDocumentProperties Property

CustomDocumentProperties Property
Pete.Wilkinson@vivista.sungard.com is offline   Reply With Quote
Old 2009-12-04   #4 (permalink)
Ingres Corp
 
Join Date: Mar 2007
Location: On the OpenROAD
Posts: 828
Default

This is the difference between documentation and implementation.
Microsoft can document the attributes to be a certain type (e.g. DocumentProperty"), but the actual implementation could be of a more generic type - as long as they only use the documented type it doesn't really matter.
This is like defining a method for a userclass to return UserObject, but documenting that it retuns a Customer object - as long as you really return a customer object this should be ok (though it will probably require some casting wherever you use the method).

Anyway I opened the Object Browser in VBA (in MS Word) and it shows the attributes as following:
Property BuiltInDocumentProperties As Object
read-only
Member of Word.Document
Property CustomDocumentProperties As Object
read-only
Member of Word.Document

So, it's actually defined as "Object" which is exactly what I wrote - a generic COM object reference.
There is also no "DocumentProperty" class in the Word library.
But it can be found in the "Office" library.

So, what I did in OpenROAD 2006 is:
I added both "word" (Microsoft Word Object Library) and "office" (Microsoft Office Object Library) as extenal class libraries.
Having a look at the class browser it shows "builtindocumentproperties" as type "builtindocumentproperties" and "customdocumentproperties" as "customdocumentproperties".
This means that it can't determine the actual type of these object attributes.
But the "documentproperty" class does not show up - and I can't declare a variable of this type.
Why is that: oleview gave me the answer:
DocumentProperty is actually not a class, but an interface. The same applies to DocumentProperties

The OpenROAD's ClassBrowser only shows classes.
Therefore in order to work with their attributes/methods you have to use a class which implements these interfaces.

Hope this clarifies.
Bodo is offline   Reply With Quote
Old 2009-12-04   #5 (permalink)
Ingres Community
 
Join Date: May 2007
Posts: 52
Default

you certainly have more of a grasp on the details then I do Bodo; all I know is that I should be able to do something like the following, but I cannot:

myDoc.CustomDocumentProperties.Add ( ... )

I suspect the issue is, is that DocumentProperties is defined/declared within the Office Library and not directly in the Word Library, though Word must surely inherit from Office?, and such code above would work in VBA. But as you say documentation is not always implemenation, and OR implementation differs from VBA implementation.

I have put the code into a Macro which I call via myWord.Run ( myMacroName ), which will surfice for now, I might yet put it into VBA dll, but to do it in OR would have been the prefered solution.
Pete.Wilkinson@vivista.sungard.com is offline   Reply With Quote
Old 2009-12-04   #6 (permalink)
Ingres Corp
 
Join Date: Mar 2007
Location: On the OpenROAD
Posts: 828
Default

What you should be able to do is:
Code:
declare
    methodname = varchar(32) not null;
    ...
enddeclare
{
...
methodname = 'Add';
myDoc.CustomDocumentProperties.:methodname ( ... );
}
Bodo is offline   Reply With Quote
Old 2009-12-04   #7 (permalink)
Ingres Community
 
Join Date: May 2007
Posts: 52
Default

Fantastic stuff, not sure why it works, but it does!

Many thanks Bodo!
Pete.Wilkinson@vivista.sungard.com is offline   Reply With Quote
Old 2009-12-04   #8 (permalink)
Ingres Corp
 
Join Date: Mar 2007
Location: On the OpenROAD
Posts: 828
Default

As CustomDocumentProperties attribute is not defined as "DocumentProperties" in the COM library you can't directly invoke "Add" method on it - for the same reason you don't get the auto-completion offering when typing "mydoc.CustomDocumentProperties." in VBA.
The dynamic invocation works, because the compiler doesn't check if the method is defined for the class of the object - it can't do that as it doesn't know its name until runtime.
At runtime the method is just executed on the object - if the method is defined for the actual object referenced then it's ok - if not then a runtime exception/error would be generated.
Bodo is offline   Reply With Quote
Old 2010-02-12   #9 (permalink)
Ingres Community
 
Join Date: May 2007
Posts: 52
Default

Further to this, I now really need to be able to access any existing document properties, so I am able to amend or delete. To do this I guess will I need some wrapper around the Office object or something? I'm well out of my depth here I'm afraid.
Pete.Wilkinson@vivista.sungard.com is offline   Reply With Quote

Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


LinkBacks (?)
LinkBack to this Thread: http://community.ingres.com/forum/openroad-developers-forum/11448-word-office-activex-document-properties.html
Posted By For Type Date
Word / Office ActiveX - Document Properties - Ingres Community Forums This thread Refback 2009-12-03 01:52 PM

© 2009 Ingres Corporation. All Rights Reserved