Consulting

Results 1 to 2 of 2

Thread: Opening Word From VBA

  1. #1
    VBAX Newbie
    Joined
    Aug 2013
    Posts
    1
    Location

    Opening Word From VBA

    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

  2. #2
    Quote Originally Posted by harvlake View Post
    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
    Boyd Trimmell aka HiTechCoach
    Microsoft Access MVP -2010-2015

    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •