Consulting

Results 1 to 15 of 15

Thread: Custom Document Property Defaults

  1. #1
    VBAX Newbie
    Joined
    Feb 2007
    Posts
    5
    Location

    Custom Document Property Defaults

    I have been using VBA to read/write custom document properties via the CustomDocumentProperties collection.

    When you open a workbook & go to File -> Properties -> Custom , Microsoft has thoughtfully provided a default list of ~ 27 suggested custom properties: 'Checked By', 'Client', 'Date Completed', ...... 'Typist'.

    Can anyone suggest a way that this default list can be addressed and/or edited in VBA, so that it can be populated it with a different list ??


    Thanks ....

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Sub SetCustomProperties(prop As String, val, valtype As MsoDocProperties)

    With ActiveWorkbook
    On Error Resume Next
    .CustomDocumentProperties(prop).Delete
    On Error GoTo 0
    .CustomDocumentProperties.Add Name:=prop, _
    LinkToContent:=False, _
    Value:=val, _
    Type:=valtype
    End With

    End Sub

    Public Sub TestCustomProperties()

    SetCustomProperties "Client", "Exxon", msoPropertyTypeString
    SetCustomProperties "Start Date", Date, msoPropertyTypeDate

    End Sub
    [/vba]

  3. #3
    VBAX Newbie
    Joined
    Feb 2007
    Posts
    5
    Location
    Thanks xld,

    Your code sets a new custom property, but it does not change the default list supplied by Microsoft, which includes: 'Checked By', 'Client', 'Date Completed', ...... 'Typist' etc.

    Any clues as to how to change the default list ?

  4. #4
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    You'd need to go after the BuiltInDocumentProperties:

    [vba] Dim l As Long
    With ActiveWorkbook
    For l = 1 To .BuiltinDocumentProperties.Count
    .BuiltinDocumentProperties(l).Value = "Modified"
    Next l
    End With[/vba]

    You can't delete or rename the properties, though, but you can change their values.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Linus_99
    Thanks xld,

    Your code sets a new custom property, but it does not change the default list supplied by Microsoft, which includes: 'Checked By', 'Client', 'Date Completed', ...... 'Typist' etc.

    Any clues as to how to change the default list ?
    If by this you mean that you want to remove say the Client property, not its value but the property itself, you are out of luck, they are locked down.

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Ken Puls
    You'd need to go after the BuiltInDocumentProperties:

    [vba] Dim l As Long
    With ActiveWorkbook
    For l = 1 To .BuiltinDocumentProperties.Count
    .BuiltinDocumentProperties(l).Value = "Modified"
    Next l
    End With[/vba]
    You can't delete or rename the properties, though, but you can change their values.
    What's the point of this code Ken? All it does is put Modified in a number of properties, and then fails when it tries to pout the text in a numeric property.

  7. #7
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    I was just pointing out how you can change the BuiltIn property values, that's all. The main point of the post was that you couldn't delete/modify the actual names.

    Should have been more clear on that, and only chosen one, but there you have it.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  8. #8
    VBAX Newbie
    Joined
    Feb 2007
    Posts
    5
    Location
    Quote Originally Posted by xld
    If by this you mean that you want to remove say the Client property, not its value but the property itself, you are out of luck, they are locked down.
    Yes, the aim was to remove the 'Checked By', 'Client', 'Date Completed', ...... 'Typist' properties all together and replace them with our own list of custom properties called say "Prop1", "Prop2", "Prop3" etc.

    I suppose the consensus is that it cannot be done ??

  9. #9
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Quote Originally Posted by Linus_99
    I suppose the consensus is that it cannot be done ??
    Correct.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    But you can still add your own.

  11. #11
    VBAX Newbie
    Joined
    Feb 2007
    Posts
    5
    Location
    Thanks for the replies.

    No problems adding/changing/deleting custom properties and values with VBA as discussed above, but it's just really annoying having the Microsoft suggested list of property names in that listbox.

    We are trying to deploy some documents (Excel and Word) across an organisation with a standard set of custom properties defined by our client, & it's distracting for users to be prompted with unwanted property names when they opn the document's property tab.

    I've searched high & low for how to do this, but it looks like dead end ....

  12. #12
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    How are you prompted. I open properties dozens of times and I have never been propmpted. Those properties are there, but I ignore them.

  13. #13
    VBAX Newbie
    Joined
    Feb 2007
    Posts
    5
    Location
    My mistake: Not prompted, but our application would be improved if they could be replaced by the names of the set of properties we need to use.

  14. #14
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    I don't get it. Why? It's hardly like they come up and announce themselves to you unless you go into the screen.

    Seems like an easy workaround would be to create a userform that is only populated with the Custom properties if it's really that irritating...
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  15. #15
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Ken Puls
    I don't get it. Why? It's hardly like they come up and announce themselves to you unless you go into the screen.

    Seems like an easy workaround would be to create a userform that is only populated with the Custom properties if it's really that irritating...
    Seems to me that someone has too much time on their hands.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •