Originally Posted by
harvlake
Hi, I hope you can help. We have an access application and in it we open a word document and print it using
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
Set objDoc = objWord.Documents.Add()
objWord.PrintOut , , , , , , , , , , , , LWordDoc
We have a digital signature that takes a few moments to verify the signature. With out that time, we have an invalid signature.
Is it possible to open the doc, delay, the print it?
Any suggestions are appreciated.
Thanks
Here is how I do it.
Place the following code in a new code module named modAPI
Private Declare Sub APISleep Lib "kernel32" Alias "Sleep" (ByVal lngMilliseconds As Long)
Public Function Sleep(lngSeconds As Long) As Boolean
If lngSeconds > 0 Then
Call APISleep(lngSeconds * 1000)
Sleep = True
End If
End Function
Now you can call the Sleep() from VBA code anywhere in you database.
Example:
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
Set objDoc = objWord.Documents.Add()
' have Access wait 10 seconds
Sleep 10
objWord.PrintOut , , , , , , , , , , , , LWordDoc