PDA

View Full Version : error



loredana
06-12-2013, 01:05 PM
Hello! I m new on this site and if I make mistakes, please excuse my english.
I want to send an e-mail (template e-mail) from excel to outlook, but when I run the macro it appears an error: Compile error: Variable not defined. I dont know what is the error. If I analyse the text I find everything ok! Please help me!
The error appears on the beginning of this text ( the Sub SendMassEmail () is marked with yello w when i run the macros):

Sub SendMassEmail()
row_number = 1

Do
DoEvents
row_number = row_number + 1
Dim mail_body_message As String
Dim Clientname As String
Dim Referinta As String
Dim Nr_contract As String
Dim Data_contract As String
Dim Clientname As String
Dim Departament As String
mail_body_message = Sheet1.Range("J2")
Clientname = Sheet1.Range("C" & row_number)
Referinta = Sheet1.Range("B" & row_number)
Nrcontract = Sheet1.Range("D" & row_number)
Datacontract = Sheet1.Range("E" & row_number)
Clientname = Sheet1.Range("C" & row_number)
Departament = Sheet1.Range("F" & row_number)

mail_body_message = Replace(mail_body_message, "replace_name_here", Clientname)
mail_body_message = Replace(mail_body_message, "ref_code", Referinta)
mail_body_message = Replace(mail_body_message, "ctr_number", Nr_contract)
mail_body_message = Replace(mail_body_message, "date", Data_contract)
mail_body_message = Replace(mail_body_message, "replace_name_here", Clientname)
mail_body_message = Replace(mail_body_message, "replace_dep_here", Departament)


MsgBox mail_body_message
'Call SendEmail(Sheet1.Range("A" & row_number, "This is a test e-mail", mail_body_message)
Loop Until row_number = 4

MsgBox "Complete!"

End Sub


Thank you!

xls
06-16-2013, 09:26 PM
hi
change row_number = 1 to Const row_number = 1

HTH//XLS

loredana
06-17-2013, 12:28 PM
Hi!
Thank you very much for your response.
I change the row_number = 1 with Const row_number = 1 but it doesn't work. It appears a new error with this message: <<Compile error: Assignment tp constant not permitted>>.

Please help me!

Yhank you!

xls
06-18-2013, 09:23 AM
please attach your sheet with macro

bradely
07-12-2013, 09:46 PM
Hey guys! Can you tell me how to create new sheet on excel forum because I nearly used excel from last week so many problems occurs during working,
thanks in advance :)

Aussiebear
07-15-2013, 07:01 PM
Hey guys! Can you tell me how to create new sheet on excel forum because I nearly used excel from last week so many problems occurs during working,
thanks in advance :)

That is a somewhat confusing post. Please re think your issue and post again.