Opening a Word template.

dylanmendes

Member
Joined
Aug 30, 2005
Messages
11
Dear VB brains,

Im attempting to open a template (.dot file) via my VB application. The intention is to open a new document based on the template as opposed to the template itself i.e. were trying to reproduce the "file -> NEW" menu functionality!

.. and all of this works very well..

NOT!!!!

The document opens as expected but when I attempt to close the session, I get a message telling me that the "normal.dot" file is in use by another application. I understand that this "normal.dot" file is something called a Global template. Our application does not explictly open this file.

How can I avoid the above message at the time of closing the application?

Thanks,

Dylan
 
Code snippet...

Hi.. thanks for your prompt response. Here it is:

Code:
Private Sub Command1_Click()
Dim appWord As New Word.Application

    appWord.Visible = True

    

    appWord.Documents.Add ("C:\XYZ\abc.dot")

End Sub
 
I have also the same problem, but it doesnt happens always

What i have found :
If an instance of winword.exe is already running, (like an opened word document, or just Outlook 2003 running (spell checker is using word)) the problem occurs
If no winword.exe is running, the msg about the normal.dot does not appear
 
You could try and get the existing instance using getObject:

Code:
Dim objWord as Object=Microsoft.VisualBasic.Interaction.GetObject(,"Word.Application")
dim wdApp as Word.Application
if objWord is nothing then
wdApp=New Word.Application
wdApp.Visible=true
else
wdApp=Ctype(objWord,Word.Application)
end if

This way you wont be creating a new instance if it alreday exists.

:)
 
Back
Top