none
Templates - not opening as .docm RRS feed

  • Question

  • Hi everyone,

    This is my first time posting a question. I've been put in the "enviable" position of taking over the development and implementation of a custom ribbon which allows users to open templates stored in a network share via a custom ribbon. The contractor in charge of this project no longer works for us. I haven't done this type of work before. I'm working things out but I need a hand.

    We have some .dotm files in the network share. When I double click on them they load as a .docm. If I access the same files through the custom ribbon they load as a .dotm and when you choose save the file type defaults to .dotm. I'd like to have the file open as a .docm.

    I'm guessing this is to do with how the file is called.  Below is he code used when the user double clicks one of the templates displayed in a pop out form in Office.  From what I’ve been reading Documents.Open is not the method I need to open the file as a .docm.   Is there a method which will load .dotm as a .docm and also fit nicely into the below cde?  I see there is a  Template.OpenAsDocument method but that relies on a collection which isn’t configured.

    Thanks for your help.

    Private Sub cmdOpen_Click()
    Dim i As Variant
        For Each i In Me.lstFiles.List
            If Me.lstFiles.ListIndex <> -1 Then
                Documents.Open FileName:=sPath & Application.PathSeparator & Me.lstFiles.Value, ReadOnly:=True
                Me.Hide
                Unload Me
                Exit Sub
            Else
                MsgBox "Please select a file."
                Exit Sub
            End If
        Next i
    End Sub
    
    Private Sub lstFiles_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
        Documents.Open FileName:=sPath & Application.PathSeparator & Me.lstFiles.Value, ReadOnly:=True
        Me.Hide
        Unload Me
    End Sub

    Wednesday, October 23, 2013 6:56 PM

Answers

  • Hi,

    The .dotm document is a Word Macro-Enabled Template file and the .docm document means a Word Macro-Enabled Document.

    If you double click the dotm template, it will automatically create a new document which displays as a .docm document based on the dotm template. But when you open the dotm file by the ribbon button, Word will open the dotm document for editing.

    If you use the Documents.Open method, it means you want to open the template document.

    When you want to create a new document based on the dotm template, I suggest you use the Documents.Add method.

    Here is a sample for your reference.

    Documents.Add Template:=sPath & Application.PathSeparator & Me.lstFiles.Value


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by XTIT Thursday, October 24, 2013 6:18 PM
    Thursday, October 24, 2013 3:26 PM
    Moderator

All replies

  • Hi,

    The .dotm document is a Word Macro-Enabled Template file and the .docm document means a Word Macro-Enabled Document.

    If you double click the dotm template, it will automatically create a new document which displays as a .docm document based on the dotm template. But when you open the dotm file by the ribbon button, Word will open the dotm document for editing.

    If you use the Documents.Open method, it means you want to open the template document.

    When you want to create a new document based on the dotm template, I suggest you use the Documents.Add method.

    Here is a sample for your reference.

    Documents.Add Template:=sPath & Application.PathSeparator & Me.lstFiles.Value


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by XTIT Thursday, October 24, 2013 6:18 PM
    Thursday, October 24, 2013 3:26 PM
    Moderator
  • Thanks for that it.  It works a treat.

    Some of the files I am trying to open are shortcuts to templates.  If I use the Document.Add Template method to open these files it tries to interpret the shortcuts as a template and dumps a bunch of garbage text into a document.  Is there a way to have Word use the template the shortcut links to?

    Thursday, October 24, 2013 6:23 PM
  • I've solved my second issue.

    I've incorporate the code from this page and I've now got the result I'm after.

    http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=44596&lngWId=1

    Thanks agian Luna.

    Thursday, October 24, 2013 10:28 PM