Consulting

Results 1 to 6 of 6

Thread: error

  1. #1
    VBAX Newbie
    Joined
    Jun 2013
    Posts
    2
    Location

    error

    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):

    [VBA]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[/VBA]


    Thank you!

  2. #2
    VBAX Regular xls's Avatar
    Joined
    Aug 2005
    Posts
    76
    Location
    hi
    change [VBA]row_number = 1[/VBA] to [VBA]Const row_number = 1[/VBA]

    HTH//XLS
    Winners dont do different things, they do things differently.

  3. #3
    VBAX Newbie
    Joined
    Jun 2013
    Posts
    2
    Location
    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!

  4. #4
    VBAX Regular xls's Avatar
    Joined
    Aug 2005
    Posts
    76
    Location
    please attach your sheet with macro
    Winners dont do different things, they do things differently.

  5. #5
    VBAX Regular
    Joined
    Jul 2013
    Posts
    8
    Location
    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

  6. #6
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,053
    Location
    Quote Originally Posted by bradely
    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.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •