Code: Select all
Sub Labels()
Documents.Add Template:=ThisDocument.Path & "\" & "MMC Shipping Labels.dot", _
NewTemplate:=False, DocumentType:=0
End Sub
I used ThisDocument.Path & "\" in place of H:\Templates\Word\
The upgraded code works fine on my Win7HP/Office2003 Notebook.
The upgraded code works fine on my Win7SE/Office2007 Netbook.
The upgraded code fails on my client's client's new Win7/Office2010 machine.
And I am ashamed/sorry to say that I was so flustered last night that I neglected to take a PrtScr of the screen, or to note the run-time-error in full.
The RTE was along the lines of "badly formed file name", I remember that, because I dropped into the Immediate pane and interrogated the value of ThisDocument.Path & "\" & "MMC Shipping Labels.dot" .
It looked fine.
I wrapped it in a FileLen() function and got back a value of about 32,000, which seemed reasonable to me.
So that FileLen accepted the name but Documents.Add didn't.
I tried removing the space in the file name (both in Explorer and in the VBA code). Same error.
The only thing I can think of is that Office2010, unlike Office2007, requires a dotX extension, but this morning I have no easy way of testing that theory.