#1
|
|||
|
|||
Access Document Property that appears in Panel but cannot find using VBA
Hi,
When I display the document panel I have one property that is called Status. I need to write info there from a macro. I tried to access it in both ways: ActiveDocument.CustomDocumentProperties("Status"). Value = .Text ActiveDocument.BuiltInDocumentProperties("Status") .Value = .Text But both don't work. It seems like a Custom Property. What am I missing? Thanks, Rocky |
#2
|
||||
|
||||
Despite being listed, 'Status' is the name of a Custom Document Property that you'd have to add before you can populate it. For that, you can use code like:
Code:
Function SetStatusProperty(wdDoc As Document, StrProp As String, StrTxt As String) Dim i As Long, bAdd As Boolean bAdd = True With wdDoc.CustomDocumentProperties For i = 1 To .Count If .Item(i).Name = StrProp Then .Item(StrProp).Value = StrTxt bAdd = False Exit For End If Next If bAdd = True Then .Add Name:=StrProp, LinkToContent:=False, Value:=StrTxt, Type:=msoPropertyTypeString End With End Function Code:
Sub Demo() SetStatusProperty ActiveDocument, "Status", "ABC" MsgBox ActiveDocument.CustomDocumentProperties("Status").Value End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Can there be two properties with the same name?
When I add it - the value changes when I open the document properties window. But in the document panel the value does not change. Which means there are two properties called status?
When I go into the document properties custom window - I do see a property called status, even before I add it in the code, but I can't delete it. Is there another custom property or built-in property that should be accessed in a different way? |
#4
|
||||
|
||||
I'm not sure what you mean by "in the document panel the value does not change" - it does with the code I posted. And, no, you can't delete 'Status' from the list. Regardless, that's the one the code I posted updates. Update it manually and you'll see the same result.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
It does not change in the document panel. I see it above the document and it remains empty.
However, when I go to File->Info and open the Advanced Properties it does have the correct value. It seems that when I go to File->Properties->Show Document Panel, I see another property called Status. Where could that come from? |
#6
|
||||
|
||||
The behaviour you're seeing is normal - they're one and the same property.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
The problem is that they have different values. In the document panel I have a value of "HelpMe". In the advanced properties I see a value of X29.
I need to change the value in the document panel to be X29. But it does not change. Only when I manually change it. Not from a macro. Could there be another property called Status that is defined somewhere else? It is not in the builtinproperties because I looped through them. |
#8
|
||||
|
||||
There is a built-in document property named 'Content Status'. Is that what you're referring to?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Yes! You were right!
In the Document Panel the label is Status. Going manually through the Built in properties by the value I see that the name of the property is Content Status. Thanks! |
Tags |
document properties |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Userform and Document Information Panel | jkimwardtech | Word VBA | 1 | 01-21-2016 06:53 PM |
Vba code to save document as pdf using document property text and rename folder. | staicumihai | Word VBA | 1 | 12-21-2015 07:39 AM |
Document Property Question | ksigcajun | Word VBA | 9 | 10-14-2014 11:26 AM |
Cannot access most of property of MailItem object on Windows Server 2008 64 bit | tz900 | Outlook | 0 | 04-10-2012 12:55 PM |
Access to the property of the current table | b0x4it | Word VBA | 2 | 05-26-2011 06:25 AM |