Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    Auckland, North Island, New Zealand
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CustomDocumentProperties

    Anyone know how to create one of these in VBA?

  2. #2
    Star Lounger
    Join Date
    Jan 2001
    Location
    Adelaide, South Australia, Australia
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CustomDocumentProperties

    ActiveDocument.CustomDocumentProperties.Add

    Office 2000 VBA Help has the following example:

    <pre>With ActiveDocument.CustomDocumentProperties
    .Add Name:="CustomNumber", _
    LinkToContent:=False, _
    Type:=msoPropertyTypeNumber, _
    Value:=1000
    .Add Name:="CustomString", _
    LinkToContent:=False, _
    Type:=msoPropertyTypeString, _
    Value:="This is a custom property."
    .Add Name:="CustomDate", _
    LinkToContent:=False, _
    Type:=msoPropertyTypeDate, _
    Value:=Date
    End With
    </pre>


    Ian.

  3. #3
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Kortrijk, Belgium
    Posts
    571
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CustomDocumentProperties

    You first have to select File >> Properties >> click the Custom tab. Then you have to add values for predefined 'names' or you can define new names and add a value. The custom names should appear in the lower box. Then you have defined customproperties and you can use the following code:
    <pre>Sub CDP()
    Dim rw as integer
    Dim p
    rw = 1
    Worksheets(1).Activate
    For Each p In ActiveWorkbook.CustomDocumentProperties
    Cells(rw, 1).Value = p.Name
    Cells(rw, 2).Value = p.Value
    rw = rw + 1
    Next
    End Sub
    </pre>


    I haven't tried out to record a macro while creating some customdocumentproperties, but I think this will lead you to the code you want. Hope this helps.

Posting Permissions

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