Word Automation \ global template issue

L

Lee.Westcott

Hi,

Not sure if this is the correct group but here goes.....

I have inherited a VB 6.0 app and as part of its functionality, it
creates a Word 2003 document from a saved custom template then
printouts the page before closing.

The issue being reported is that if the user already has word running,
after creating a new document from the VB application, Word then says
that "Normal.dot" is in use and cannot be saved.

In a nutshell, this process should all be seemless \ transparent
without out prompts from Word. I am told this was the case before the
upgrade from a previous version of word (2002).

The Code being used is....

'Set objWrdDoc = GetObject(, "Word.Application")

If objWrdDoc Is Nothing Then
bNewWrdApp = True
Set objWrdDoc = CreateObject("Word.Application")
End If

' Associate our custom template with word instance.
Set doc = objWrdDoc .Documents.Add("MyFile.dot")
'
'
' Assignment of data to bookmarks etc
'
'
'

objWrdDoc.Application.PrintOut
objWrdDoc.ActiveDocument.SaveAs "My.doc"
objWrdDoc.Application.DisplayAlerts = False

Do While objWrdDoc .BackgroundPrintingStatus = 1
Loop

'If bNewWrdApp = True Then
objWrdDoc.Application.Quit
objWrdDoc.Application.DisplayAlerts = True
Else
doc.Close
End If


Set doc = Nothing
Set objWrdDoc = Nothing
 
J

Jonathan West

Add the following line just before the Application.Quit

objWrdDoc.Application.NormalTemplate.Saved = True

This will kid Word into believing that nothing in normal.dot has changed,
and so it doesn't need to be saved when Word is closed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top