Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

turning off word 97 warnings re slow running during mailmerge?

Status
Not open for further replies.

dongledell

Technical User
Dec 10, 2002
26
GB
I've managed (after a fashion!) to get access 97 and word 97 to communicate and do what I want them to do (sort of!!!) BUT there is a minor problem. Sometimes (for reasons which I am yet to fathom) it runs REALLY slowly. Frankly I dont care about that - I think the whole thing that I am having to do at the moment is a total waste of time, and I'm not going to be using it, so they want to waste my time, they can live with having there own time wasted!!!


Or at least, I wouldn't care but for a minor problem.... after so long Word decides your probably bored of waiting for it to finish doing it's thing and pops a handy little prompt screen up that says " this is taking longer than expected, do you want to continue to wait"... which causes an automation error in the code :(

I've tried adding .application.displayalerts=wdalertsnone", but it makes no difference whatsoever. Any ideas how I can get it to not display this, just to carry on regardless? Failing that, anyone tell me why the following code occasionally runs seriously slowly? cheers!

Code:
Public Function OpenWordDocs(ByVal strWrdDocName As String, strDBmergeSource As String, _
 strTblMergeSource As String)
 
Dim objWord As Word.Document
Dim wrdMerge As Word.MailMerge

Set objWord = GetObject(strWrdDocName, "Word.Document")
Set wrdMerge = objWord.MailMerge

objWord.Application.Visible = True

objWord.Application.DisplayAlerts = wdAlertsNone

With wrdMerge
.OpenDataSource Name:=strDBmergeSource, LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="TABLE " & strTblMergeSource
.Destination = wdSendToNewDocument
.Execute
End With

With objWord
.Application.Options.PrintBackground = False
.Application.ActiveDocument.PrintOut
.Application.quit wdDoNotSaveChanges
End With

objWord.Application.DisplayAlerts = wdAlertsAll

End Function

Also.... one thing I've never done is put in any error handling - at the moment if this code errors (for example due to the slow running) the error it gives is very non-commital. Is there any way to make it give clearer indications of where it's gone wrong rather than just say the really helpful "error"?

Please feel free to laugh and rip my code apart, I'm not afraid to admit I'm both not very advanced at this, and a bit rubbish to be frank!!!
 
Have you turned off Access warning messages?

Code:
Public Function OpenWordDocs(ByVal strWrdDocName As String, strDBmergeSource As String, _
 strTblMergeSource As String)
 
[COLOR=blue]Docmd.SetWarnings False[/color]
.....
.....
.....
[COLOR=blue]Docmd.SetWarnings True[/color]

End Sub

As far as the slow running goes, have you tried setting a breakpoint in the code and stepping through the routine? If there is a significant delay in any one line of code, you should be able to spot it this way.

HTH
Lightning
 
hi, thanks for the reply Lightning,

yeah I have tried the warnings off in access - made no difference.

Have to admit, I still haven't quite worked out how to do this breakpoint thing and have it work - always seems to go wrong when I try! Couldn't possibly give some examples in the above code could you please?

Many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top