locked
Bugs with CopyStylesFromTemplate? RRS feed

  • Question

  • Is anyone aware of any bugs with CopyStylesFromTemplate? I am using a .dot template in Word 2010. My code worked just fine until we made an update to our Word template; now Word crashes when this method is applied. I'm not sure what to look for, since I can't get an error.

    The code is below.

    Private Function newScML(Optional ByVal visible As Boolean = True, Optional ByVal filename As String = vbNullString) As Document
    
    Dim newDoc As Document
    Dim scmlTempLoc As String
    
    scmlTempLoc = 'My template location here
    
    Set newDoc = Documents.Add(visible:=visible)
    ' The following line is where Word crashes.
    newDoc.CopyStylesFromTemplate (scmlTempLoc)
    
    If filename <> vbNullString Then newDoc.SaveAs2 filename
    
    Set newScML = newDoc
    
    End Function

    The template location is definitely good; it has not been changed.

    Edit: This seems to be a Mac/PC compatibility issue (the template was created in Mac 2011). Still not sure what the difference is, or what to look for in the future, but I have a workaround of moving all of the styles into a new document and saving that as the template for PC users.
    • Edited by cchimi Thursday, March 14, 2013 9:00 PM Additional detail.
    Thursday, March 14, 2013 3:07 PM