?
Solved

Displaying an Array in a MsgBox

Posted on 2006-07-07
3
Medium Priority
?
371 Views
Last Modified: 2010-04-08
I have a text file which has each persons name and their email, (eg. John Smith=john.smith@abc.com) and i have code which tests to see whether a pdf pay slip exists (eg.John Smith Pay Slip.pdf). What i want to do is display the values of the array of people who do not have a pay slip for the particlaur period, into a msgbox and the same for the ones who do. (lines ****). Any ideas of how to even assign these values to 2 different arrays which could be displayed?




For intCounter = LBound(arrFiles) To UBound(arrFiles)
            strFilename = "H:\Files\" & arrFiles(intCounter) & " " & "Pay Slip.pdf"
            If objFSO.FileExists(strFilename) Then
 *****               'store values of names who DO have files
                Set olkMessage = Application.CreateItem(olMailItem)
                With olkMessage
                    .Subject = "Pay Slip" & " for " & Mid(strFolder, 4, Len(strFolder) - 3)
                    .Body = "Here's your pay slip."
                    'Change the file name and path on the following line as desired
                    .Attachments.Add strFilename
                    .Recipients.Add arrAddresses(intCounter)
                    .Send
                End With
            Else
 *****               'store names of files which DO NOT exist
                End If
        Next
0
Comment
Question by:james_daley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 17060980
Hi james_daley,

Rather than use an array it'd be far simpler to store them in two string variables.  Something like this:

    Dim strNamesWithSlips As String, _
    strnamesWithoutSlips As String
    For intCounter = LBound(arrFiles) To UBound(arrFiles)
            strFilename = "H:\Files\" & arrFiles(intCounter) & " " & "Pay Slip.pdf"
            If objFSO.FileExists(strFilename) Then
                strNamesWithSlips = strNamesWithSlips & arrFiles(intCounter) & vbCrLf
                Set olkMessage = Application.CreateItem(olMailItem)
                With olkMessage
                    .Subject = "Pay Slip" & " for " & Mid(strFolder, 4, Len(strFolder) - 3)
                    .Body = "Here's your pay slip."
                    'Change the file name and path on the following line as desired
                    .Attachments.Add strFilename
                    .Recipients.Add arrAddresses(intCounter)
                    .Send
                End With
            Else
                strNamesWithoutSlips = strNamesWithoutSlips & arrFiles(intCounter) & vbCrLf
            End If
    Next
    MsgBox "The following staff have pay slips: " & strNamesWithSlips & "The following staff do not have payslips: " & strNamesWithoutSlips

Cheers!
0
 
LVL 1

Author Comment

by:james_daley
ID: 17070632
Thanks very much. Once again you've come to the rescue!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17071335
You're welcome.  Always happy to be able to help out.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question