LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modify word2003 CustomDocumentProperties

Hi,

 

There is a problem when modifing "CustomDocumentProperties" in Word2003 by using Labiew 8.5.

 

I've found MSDN that this function can be realized by the following VB code.

 

Word.Application.Documents.CustomDocumentsProperties.Item("Your Name").Value

 

But Labview 8.5 looks "Word.Application.Documents.CustomDocumentsProperties" as Variant Type Data output, no any "Item" methods to call. So is there anybody can help me to solve it?

 

Thank you very much.

 

Max Li

0 Kudos
Message 1 of 12
(5,218 Views)
Please attch that part of the code for easy examination
0 Kudos
Message 2 of 12
(5,205 Views)

Exaclty the same problem with LabVIEW 2009/2010 (SP1) and Word 2003/2007 under Windows XP 32bit and Windows 7 64bit!

 

The property "CustomDocumentProperties" should return an object not a variant (http://msdn.microsoft.com/en-us/library/bb214837(v=office.12).aspx)

 

The variant seem to be a pointer but I was unable to correctly recover the original object.

 

Attached the vi I've used to do some tests.

 

Any help or suggestion will be really appreciated. 

0 Kudos
Message 3 of 12
(5,004 Views)

The Report Generation Toolkit use the VBProject property of the Document object to create, run and then delete a VBA code module to modify the document property. I would suggest you use this approach to modify the custom document properties. Note that you will have to modify the word security to allow VBA project to run (tools, options, security, macro security, trusted publishers, allow VBA project, this is from memory so it may not be the exact path).

 

Ben64

0 Kudos
Message 4 of 12
(4,987 Views)

It isn't necessary to use the Report Generation Toolkit to modify the CustomDocumentProperties.

 

I verified it with a Word 2003 file on Windows XP.

 

Use ActiveX automation and DsoFile.dll available from http://support.microsoft.com/kb/224351

 

I am not sure how it works with Word 2010 and Win7 since right-clicking on a file for its properties in Windows 7 doesn't show the same information as in Win XP.

 

 

0 Kudos
Message 5 of 12
(4,984 Views)

@nyc_(is_out_of_here) wrote:

It isn't necessary to use the Report Generation Toolkit to modify the CustomDocumentProperties.

 

 



Of course it is not necessary. I just precised how it is done in the RGT. The same approach can be done using only activeX properties and methods. I've done it for word and excel and it works fine.

 

 

Ben64

0 Kudos
Message 6 of 12
(4,978 Views)

@ben64 wrote:

The same approach can be done using only activeX properties and methods. I've done it for word and excel and it works fine.

 

 

Ben64



Can you post your VI on how to add or edit CustomDocumentProperties?

 

The OP and Danele and I can't quite figure how to access the CustomDocumentProperties. It returns a Variant which we can't figure out what to do with. You can see Danele's VI further up in this thread.

 

 

0 Kudos
Message 7 of 12
(4,973 Views)

I'll post it on monday,

 

Ben64

0 Kudos
Message 8 of 12
(4,966 Views)

When we use the add method of the Word.CustomProperties activeX class to convert the variant we only have the name and value parameters (the link to content, type and LinkSource parameters are missing). Using the Office.DocumentProperties class produce all the listed input parameters but it still produce a run time error. So a workaround is to create, run and delete a VBA module.

 

Don't forget:

 

IN WORD:
TOOLS -> OPTIONS -> SECURITY TAB -> MACRO SECURITY
-> TRUSTED PUBLISHERS TAB ->
CHECK TRUST ACCESS TO VISUAL BASIC PROJECT

 

Ben64

Message 9 of 12
(4,947 Views)

Thank you for that.

 

I had been hoping there was a way to do it without resorting to calling a VBA module.

0 Kudos
Message 10 of 12
(4,945 Views)