Custom form printing using Word template cause Outlook to crash

S

Sandee911

Hi there,

I'm using the word template solution to print data from outlook custom forms

Set oWordApp = CreateObject("Word.Application")
If oWordApp Is Nothing Then
MsgBox "Couldn't start Word."
Else
Dim bolPrintBackground
Dim template
template = "http://whatever/template.dot"
Set oDoc = oWordApp.Documents.Add(template)
strMyField = Item.UserProperties.Find("YourName")
oDoc.Bookmarks("YourName").Range.InsertAfter strMyField
....set all bookmarks...
bolPrintBackground = oWordApp.Options.PrintBackground
oWordApp.Options.PrintBackground = False
oDoc.PrintOut
oWordApp.Options.PrintBackground = bolPrintBackground
Const wdDoNotSaveChanges = 0
oDoc.Close wdDoNotSaveChanges
oWordApp.Quit
Set oDoc = Nothing
Set oWordApp = Nothing
End If

But on some computers, this code is causing Outlook to crash. From what I've seen, crash happen when user click the print button that call this code, then click to close the form before printing is done (can take a few seconds), then it crash (Outlook has to quit blablabla...).

There's no relation between users computers or outlook versions (some has outlook XP sp3, some has Outlook 2003, some computers are fast machine, some are older). So I don't really know...

I though maybe it could be something about using word as outlook editor then trying to close an instance of word in the code, i don't know if it make sence, I know using word template for printing is a really common way to handle printing, am I the only one who get this problem?

Thx for your help !
 

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