Link to home
Start Free TrialLog in
Avatar of joslad
joslad

asked on

Add syscmd meter to the following code.

Using Access97.  Shown below is code taken from my database, which creates email messages and places them in the Outlook Outbox.  I need to add a syscmd meter to the code to show progress.  Not in the status bar, but the msgbox sort of thing.

Could you edit the code so that when it runs, a meter will shown in the middle of the screen to indicate progress.  Also, you must include a comment above each of your additions explaining what the code does, for it to be of use to me.


Code follows:

Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
         
          Dim objOutlook As Outlook.Application
          Dim objOutlookMsg As Outlook.MailItem
          Dim objOutlookRecip As Outlook.Recipient
          Dim objOutlookAttach As Outlook.Attachment
        Dim dbs As Database, rst As Recordset
        Dim counter
       
    If IsNull(Me.txtSubject) Then
        MsgBox "You must enter a subject before despatching e-mails!"
        Me.txtSubject.SetFocus
        Exit Sub
    End If

    If IsNull(Me.txtNotice) Then
        MsgBox "You must enter text before despatching e-mail!"
        Me.txtNotice.SetFocus
        Exit Sub
    End If

    ' Return reference to current database.
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tempFaxtest")
    ' Populate Recordset object.
    rst.MoveLast
    ' Return to first record.
    rst.MoveFirst


          ' Create the Outlook session.
          Set objOutlook = CreateObject("Outlook.Application")
            Do While Not rst.EOF
          ' Create the message.
          Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
       
              With objOutlookMsg
              ' Add the To recipient(s) to the message.
              'Set objOutlookRecip = .Recipients.Add(Me![txtemailaddress])
             Set objOutlookRecip = .Recipients.Add(rst.resemailtest)
             
              objOutlookRecip.Type = olTo

             
             ' Set the Subject, Body, and Importance of the message.
             .Subject = [txtSubject]
             .Body = [txtNotice]
             .Importance = olImportanceHigh  'High importance

             ' Add attachments to the message.
             If Not IsMissing(AttachmentPath) Then
                 Set objOutlookAttach = .Attachments.Add(AttachmentPath)
             End If

           
             ' Should we display the message before sending?
             If DisplayMsg Then
                 .Display

             Else
                 .Send
             End If
          End With
                     
    counter = counter + 1
    rst.MoveNext
    Loop
    Set objOutlook = Nothing
    MsgBox "There was " & counter & " e-mails sent!"
    rst.Close
    Set dbs = Nothing
End Sub
Avatar of joslad
joslad

ASKER

Edited text of question
Avatar of joslad

ASKER

Edited text of question
Are you gonna be using the progress bar meter active x?
Avatar of joslad

ASKER

Yep.  I have the developers version of Office97.


ASKER CERTIFIED SOLUTION
Avatar of Helicopter
Helicopter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joslad

ASKER

Excellent answer and works perfectly.  Thanks Helicopter...

regards