Consulting

Results 1 to 4 of 4

Thread: Updating an exisitng template project

  1. #1

    Updating an exisitng template project

    Hi there

    I have an existing template project that needs to be updated. The content of the document is now out of date and I need to update this - with the current existing VBA/macros. I was hoping I would be able to update the existing template (with the new content) and resave but it turns out I cant. The existing template project is saved as a macro enabled template (.dotm) Due to permissions I cant resave over the original template so I have resaved as a new file also .dotm.

    Is there a way to update an existing template?

    I also tried creating a new blank document, importing each of the existing pieces of VBA code into the new document, and then resaving as a template project .dotm. As the existing and current template code works perfectly I thought this was a smart idea. Turns out when I add the code to the new blank document - it does not run at all. I get an error message.

    Any solutions? This is driving me crazy. I am very new at VBA and macros Thanks!

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by New Gal View Post
    Due to permissions I cant resave over the original template so I have resaved as a new file also .dotm.

    Is there a way to update an existing template?
    If it's a permissions issue, you'll need someone with the required permissions to open your modified template and save it over the original one.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Thanks. I have recreated a new template from scratch and are attempting to input my code.
    It starts off well but then I get an error 5 message displayed. It highlights the section below

    intPropertyType = .Item(strBookmark).Type


    The full section of code is

    Function AssignCustomProperty(strBookmark As String, varBookmark As Variant)
    'Used to assign custom properties
    'On Error GoTo FunctionErrors

    Dim intPropertyType As Integer

    With ActiveDocument.CustomDocumentProperties
    intPropertyType = .Item(strBookmark).Type
    .Item(strBookmark).Delete
    .Add Name:=strBookmark, _
    Value:=varBookmark, _
    LinkToContent:=False, _
    Type:=intPropertyType
    End With
    FunctionExit:
    Exit Function
    FunctionErrors:
    Call TrapErrors
    Resume FunctionExit
    End Function



    Currently I cant see any bookmarks displayed in my original document so I am unsure how to resolve the error. I thought if I re-created a bookmark in the same location as from the original document - then the code would run. Turns out I cant as I cant see them! BTW I haven't created any bookmarks in the new document. I have switched on view bookmarks in the settings but still no success. There is one bookmark in the original document 'bkmrkStart' but when I select this from the bookmark menu in word - it doesn't actually take me to any particular place in the document!

    How to resolve?

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    You need to check both the original template and your revised one for the bookmarks. If you've deleted one your macro needs, the macro will fail. You can check the list of bookmarks via Insert|Bookmark and you can check what they span clicking on the 'GoTo' button there.

    Similarly, your code's reference to CustomDocumentProperties shows that whoever created the template used some Custom Document Properties. If you haven't replicated these in your new template, the code will likewise fail. You can check the list of Custom Document Properties in the original template via File|Info>Properties>Advanced Properties>Custom; make sure your new template has the same Custom Document Properties.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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