PDA

View Full Version : Array Into Outlook Messages



D_Marcel
05-16-2014, 01:10 PM
Masters,

Greetings!
I'm finishing a small Excel project to control the employees in the context of a mentoring program. In the last part I'm coding the messages and the logic to sending them through the MS Outlook but I'm facing the "Type Mismatch" error since that I need to insert an array into the Outlook messages.

The error occurs when I'm trying to edit a registered employee and then call the routine to send the messages by pressing 'Save' and click on 'Yes' in the follow message. Strange that the error does not occur when the messages are created to a new employee, by pressing 'New', typing the data and then 'Save'.
I researched through hours but found nothing related to array into outlook messages.

I translated all the buttons, commands and messages to english and now I'm sharing this project with you in order to facilitate the understanding. There's also a list with dummy names to simulate real employees.

I would like to ask your help in this last part or give some directions of how can I code the messages. I thought about filter the target rows, then copy and paste into the message, but considering that this data will be right in the middle of the message, I don't know how to put the selected rows inside a variable.

Thanks in advance!

Kind regards,

Douglas Marcel

westconn1
05-18-2014, 02:29 AM
Coachees = Select_Members(2, Entry.Value, 1)as far as i can tell, your type mismatch is caused because you do not pass the first parameter (Operation) to the function, entry.value, i believe, is correct for the second parameter

with the very limited testing i did, passing 2 as operation, nothing was returned from the function, but no error occured


Dim Coachees, Mentees As Variant
Dim CheckCoach, CheckMentor As String
Dim TXT00, TXT01, TXT02, TXT03, TXT04, TXT05, TXT06, _
TXT07, TXT08, TXT09, TXT10, TXT11, TXT12, TXT13, TXT14, _
TXT15, TXT16, TXT17, TXT18, TXT19, TXT20, TXT21, TXT22, _
TXT23, TXT24, TXT25, TXT26, TXT27, TXT28, TXT29, TXT30, _
TXT31, TXT32, TXT33 As String
please note that variables defined like this. only checkmentor and txt33 are of type string, all the rest are of type variant

also you should specify the return type of functions, to know what variable type should match the function

snb
05-18-2014, 05:34 AM
It looks as if you 'update' the same data 4 times.
You better refer to the sheet the data are being stored.


If Confirm = vbYes Then
Plan1.columns(2).Find(Cod_Colaborador.Value,,,1).offset(,1).resize(4)=array (Cod_Coach.Value,Coach.Value,Cod_Mentor.Value,Mentor.Value)
Messenger 1, Colaborador.Value, Coach.Value, Mentor.Value
end if

D_Marcel
07-18-2014, 06:08 AM
Friends,

Sorry for bring back this thread after so much time. Certain day, after several attempts, I finally could find what I was doing wrong.

I was sending to the function 'Array_Handler' an Array containing all the employees selected. After the necessary changes, I was sending back to the sub the same Array:

Case 2 'Eliminate

Dim Tracker As Long


For Tracker = LBound(Importing) To UBound(Importing)
If Importing(Tracker) = Employee Then
Exit For
End If
Next Tracker


Importing(Tracker) = Importing(Tracker) & Chr(1)
Importing = Filter(Importing, Chr(1), False)

If Application.CountA(Importing) = 1 Then
For Each Element In Importing
Message = Message & vbCrLf & "Não há mais membros atribuídos" & Element
Next Element
Else
For Each Element In Importing
Message = Message & vbCrLf & Element
Next Element
End If


Array_Handler = Importing

Simply changing "Importing" for "Message", the problem didn't occur anymore.

Thanks for your help, thread solved!

Douglas Marcel