Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jun 2004
    Location
    Whistler, Br. Columbia, Canada
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB Code too fast - how to slow it down? (Access/Outlook 97)

    (Edited by HansV to provide link to post - see <!help=19>Help 19<!/help>)

    A continuation of an earlier question...(<post#=385783>post 385783</post#>)

    I have got Access generating an email and automatically attaching a pdf by using the following:

    Dim stAppName As String
    Dim stpdffolder As String
    Dim receipt As String
    Dim confnum As String

    confnum = Forms![RES FORM2].[RESERVATION NUMBER]

    DoCmd.Rename confnum, acForm, "email conf"
    DoCmd.OpenForm confnum, , , "[reservation number]=Forms![RES FORM2].[RESERVATION NUMBER]"
    DoCmd.PrintOut
    DoCmd.Close acForm, confnum, acSaveNo
    DoCmd.Rename "EMAIL CONF", acForm, confnum
    receipt = Forms![RES FORM2].[E-MAIL ADDRESS]

    stAppName = "C:Program FilesMicrosoft OfficeOfficeoutlook.exe /a f:accesspdf" & confnum & ".pdf /c ipm.note.confirmation /m " & receipt
    Call Shell(stAppName, 1)

    Exit_Command399_Click:
    Exit Sub

    Err_Command399_Click:
    MsgBox Err.Description
    Resume Exit_Command399_Click

    End Sub

    I had to go back to using Shell to call Outlook because, for some reason, any email address @comcast.net or @att.net would bouce if SendObject generated the email.

    The problem is that the code excutes too fast and attaches the pdf before it is finished 'printing'. This results in either a) 'outlook cannot find the file specified' or [img]/forums/images/smilies/cool.gif[/img] a 0kb attachment that is no good to anyone <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    How can I either insert a delay to give the pdf time to finish printing, or examine the pdf to ensure that it is finished printing before attempting to attach it?

    TIA

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: VB Code too fast - how to slow it down? (Access/Outlook 97)

    Perhaps the links in <post#=431634>post 431634</post#> will help.

  3. #3
    Lounger
    Join Date
    Jun 2004
    Location
    Whistler, Br. Columbia, Canada
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB Code too fast - how to slow it down? (Access/Outlook 97)

    Thanks Hans

    I wasn't able to get those solutions to work properly, however, I did use the Sleep function decribed here <post#=402867>post 402867</post#> successfully.

Posting Permissions

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