Excel 2016 having trouble creating a Word document using a template

Eagle72

New Member
Joined
Apr 5, 2005
Messages
21
Earlier versions of Excel and Word were not having this problem.
I'm getting this error: Run-time error 5981 Method 'Add' of object 'Documents' failed.

Code:
    Set wdApp = CreateObject("Word.Application") 'Create an instance of word
    Set wdDoc = wdApp.Documents.Add(QuoteDirectory & QuoteTemplate) 'Open word file
    wdApp.Visible = True

The error message pops up on the Set wdDoc... line. This worked fine in 2013 and earlier versions. It also works ok if I create a unique QuoteTemplate file for each different user that has 2016. However, I'd really prefer to have everyone use the same shared Word template.

Please help.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Have you placed a shortcut to shared templates at a network location for each user?
 
Upvote 0
Have you placed a shortcut to shared templates at a network location for each user?

I should have included the lines above it. I'm pointing to the template on the network with the code:

Code:
    QuoteDirectory = "R:\PartsQuotes\"
    QuoteTemplate = "QuoteTemplate.dot"

I had to create a new QuoteTemplate for 2016 which was not a problem. The problem is that each user seems to need their own unique template, which would be rather a hassle if we ever want to make a change to it. Also, any new employee hired will need a new template created and the code will have to handle it properly as well.

Thanks.
 
Upvote 0
I just recorded creating a new document from template in Word (2013) and had the following code (file name modified to your path & file.)
Code:
Documents.Add Template:="R:\PartsQuotes\QuoteTemplate.dotx", NewTemplate:=False, DocumentType:=0

The template I went to was a dotx file. I would assume that a dot template should be fine, but if all users are at 2007 or above the templates should be updated to dotx file format.
https://msdn.microsoft.com/en-us/library/office/ff845011(v=office.15).aspx
 
Upvote 0
I just recorded creating a new document from template in Word (2013) and had the following code (file name modified to your path & file.)
Code:
Documents.Add Template:="R:\PartsQuotes\QuoteTemplate.dotx", NewTemplate:=False, DocumentType:=0

The template I went to was a dotx file. I would assume that a dot template should be fine, but if all users are at 2007 or above the templates should be updated to dotx file format.
https://msdn.microsoft.com/en-us/library/office/ff845011(v=office.15).aspx

More info I should have mentioned up front: I have to do a bunch of work within that Word document once I create it. Therefore, the method you show creates a new Word file properly but doesn't allow you to work on it from Excel. Also, remember that the method I was previously using worked fine with 2013 and earlier versions. It is just when the second user got 2016 that this stopped working. Even the first 2016 user had no problems. It seems the template is only usable by a single 2016 user. The second 2016 user needed his own (identical) template.
 
Upvote 0

Forum statistics

Threads
1,216,671
Messages
6,132,041
Members
449,697
Latest member
bororob85

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top