Results 1 to 11 of 11
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    How to copy CustomProperties to new template (Win 2000, W2002 PS-2)

    I am using custom properties in my templates, like this one: ActiveDocument.CustomDocumentProperties("FirstTime ").

    When making a new template it would have been very useful if I could have copied them from one template to another.
    I have defined them in File/Properies/Summary/Custom. May be there are an other way of defining them such that they can be copied easely??

    Bjorn

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: How to copy CustomProperties to new template (Win 2000, W2002 PS-2)

    Two things come to mind:

    (1) When you create a new template based on an existing template, I would expect the custom properties to carry over. But I haven't tested it .

    (2) Macro to read out all custom properties from a target template/document and create/insert them into a different template/document. You might be able to use the Dsofile ActiveX component to do this without even opening the files. See MSKB 224351 - Dsofile.exe Lets You Edit Office Document Properties from Visual Basic and ASP.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: How to copy CustomProperties to new template (Win 2000, W2002 PS-2)

    Thanks jsher2000,

    I should have known about it. Used for a long time ago. Though I need to examine it more to learn how to set up the code. But if you have an example it would be easier to create my own?! (The article you gave a link to is not giving many examples.)

    I'm not making a new .dot file based on an other, but rather creating quite a new one, but I use CustomDocumentProperties instead of Bookmarks to place information on the document. Doing so the user can use track Changes without getting a bookmark content duobled up every time a track is performed (if you understand my "hieroglyphs").
    So instead of having to define every Custom Property for each template I can copy it to the new one and thus get them registered quickly.

    I can also make a code to add properties and run that every time I need to create the properties. may that is the best way. But first I need to have a list of them all.

    Well, this was "loud thinking".. Hope to be able to create the code asap.

    Thanks

    Bjorn

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: How to copy CustomProperties to new template (Win 2000, W2002 PS-2)

    Hi Bjorn, I don't have any code samples. Someday I will play with Dsofile.exe, but right now have another, more pressing project. I searched in Google, but found mostly really tiny snippets that don't add anything to what Microsoft has provided. Sorry... maybe try Usenet (Google Groups)?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How to copy CustomProperties to new template (Win 2000, W2002 PS-2)

    Bjorn,

    Even if your intention is to create a completely new template, the fastest way to "copy" all custom document properties from an existing template might be to create a new template based on the existing template, rip out all contents, and start designing.

  6. #6
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: How to copy CustomProperties to new template (Win 2000, W2002 PS-2)

    Thanks to both of you!!

    It has been a great help.

    Yes it might be most easy to copy an existing template; keeping one for that purpose only and/or making an add procedure to get them defined in the new template...

    Thanks I will try again.

    Bjorn

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: How to copy CustomProperties to new template (Win 2000, W2002 PS-2)

    All,

    While using a 'shell copy' of an existing template is a quick way to get at that template's custom document properties, it may be less than ideal in that it violates the dictum to always start building a new template starting with a clean fresh new document container - so a code solution for copying the custom document properties may be better.

    Probably the nicest way to do this would be to create an interface similar to the Organizer, but who has time? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    The following code automates the process - am attaching it as a text file due to its length.

    The code should be run with no documents/templates open - so the code should be put into a global template.
    Probably this could use some error handling, but it's late....

    Gary
    Attached Files Attached Files

  8. #8
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: How to copy CustomProperties to new template (Win 2000, W2002 PS-2)

    Thanks Gary,

    I will look into this, but it may be as you say; who has time. I'll run it asap.

    I have started with making code to add properties into a template, but your suggestion may be better. Well, its monday and a new week and a lot of other things to do.

    Bjorn

  9. #9
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: How to copy CustomProperties to new template (Win 2000, W2002 PS-2)

    Hi,

    Regarding adding Custom Properties.

    I have tried the following code to add properties when I have the template open and it looks as this is OK. I will only run this inside the open template (dot - file) when I create a new template in order to define the properties for the new template:

    Sub AddCustomProperty()
    Dim CustomProperty As DocumentProperties

    ' If a property exists it will resume on the next line
    On Error Resume Next

    Set CustomProperty = ActiveDocument.CustomDocumentProperties

    CustomProperty.Add Name:="DOCID", Type:=msoPropertyTypeString, Value:="DocID", LinkToContent:=False
    CustomProperty.Add Name:="FULLNAME", Type:=msoPropertyTypeString, Value:="FileFullName", LinkToContent:=False
    CustomProperty.Add Name:="TESTING", Type:=msoPropertyTypeString, Value:="TESTING", LinkToContent:=False
    CustomProperty.Add Name:="TESTING2", Type:=msoPropertyTypeBoolean, Value:=True, LinkToContent:=False

    End Sub

    May be this is not according to good practice, but it looks as it works.

    Bjorn

  10. #10
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    ASKER, Norway
    Posts
    277
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: How to copy CustomProperties to new template (Win 2000, W2002 PS-2)

    Thanks for the recommendation. I will change my coding accordingly.

    One learn as one go along.

    Thanks

    Bjorn

  11. #11
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: How to copy CustomProperties to new template (Win 2000, W2002 PS-2)

    <P ID="edit" class=small>(Edited by jscher2000 on 10-Aug-03 23:42. Correcting a SEVERE typo or two...)</P>Based on recent "whoops" experience doing a lot of SaveAs, I recommend interlineating your .Add statements with assignment statements. In other words:

    On Error Resume Next
    CustomProperty.Add Name:="DOCID", Type:=msoPropertyTypeString, Value:="DocID", LinkToContent:=False
    ActiveDocument.CustomDocumentProperties("DOCID").V alue = "DocID"
    CustomProperty.Add Name:="FULLNAME", Type:=msoPropertyTypeString, Value:="FileFullName", LinkToContent:=False
    ActiveDocument.CustomDocumentProperties("FULLNAME" ).Value = "FileFullName"
    ' and so forth.
    On Error Goto 0

    Otherwise, assuming your values are variables, your intended changes will be ignored; there will be neither an .Add nor an assignment.

Posting Permissions

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