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("tempFax test")
' Populate Recordset object.
rst.MoveLast
' Return to first record.
rst.MoveFirst
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Appl ication")
Do While Not rst.EOF
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMa ilItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
'Set objOutlookRecip = .Recipients.Add(Me![txtema iladdress] )
Set objOutlookRecip = .Recipients.Add(rst.resema iltest)
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(Attachmen tPath)
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
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("tempFax
' Populate Recordset object.
rst.MoveLast
' Return to first record.
rst.MoveFirst
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Appl
Do While Not rst.EOF
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMa
With objOutlookMsg
' Add the To recipient(s) to the message.
'Set objOutlookRecip = .Recipients.Add(Me![txtema
Set objOutlookRecip = .Recipients.Add(rst.resema
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(Attachmen
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
ASKER
Edited text of question
Are you gonna be using the progress bar meter active x?
ASKER
Yep. I have the developers version of Office97.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent answer and works perfectly. Thanks Helicopter...
regards
regards
ASKER