How to open Word Document based on Template?

Hi,

I have a VB.NET application that resides on notebooks which are disconnected from the Network most of the time.
I have a Word Document which is based on a template I've written.
The VB.NET application needs to be able to open up that document, save it as a new filename, change a few things, and then display it to the user.

I have no trouble with the opening, saving and changing part of this.
However, I get an error when I try to display this new document to the user on my test notebook:
"Word cannot open this document template. (C:\Program Files\...\Images\template1.dot"

The thing is, I've installed the template to the  Application Data\Microsoft\Templates folder in the users Documents & Settings folder.
The C:\Program Files\...\Images folder is where the new document I created is saved.

If I actually open that document by double clicking, then it works fine.
But using the automation below it doesn't.

   Dim objWord As New Word.ApplicationClass
   Dim objDoc As Word.Document
   Dim strDocPath as String = "C:\Program Files\...\Images\TestDocument.doc"

   objWord.Visible = True
   objDoc = objWord.Documents.Open(strDocPath)
   objDoc .AttachedTemplate = "template1"
   objDoc .Activate()

I'm sure this is to do with the template as I have no problems with other documents that use the Normal.dot template.

Can anybody help me?

Many Thanks,
Janine
janineoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

janineoAuthor Commented:
Okay, I've worked out what the problem was.

When i created the document, I based it off the template which was in the same folder as the document when i saved it.

I re-created the document, basing it off the template in the Templates directory instead.

Then, when i ran the automation on the test PC it knew where to look for the template - the templates folder, not the same directory as the document.

Phew.

Cheers,
Janine
GranModCommented:
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.