dongledell
Technical User
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!
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!!!
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!!!