none
VBA - variables RRS feed

  • Question

  • Hello,

    I have the following code in which I use some variables. Only the text appears but without the values of the variables.

    Sub EmailAllwithsignature()
    Dim oApp As Object
    Dim oMail As Object
    Dim SendToName As String
    Dim theSubject As String
    Dim Sendtocc As String
    Dim theBody As String
    Dim Contract As String
    Dim Object As String
    Dim ExecPercent As String
    Dim EndDate As Date
    
    
    For Each c In Selection 'loop through (manually) selected records
    
    
        SendToName = Range("C" & c.Row)
        theSubject = Range("J" & c.Row)
        Sendtocc = Range("D" & c.Row)
        theBody = Range("K" & c.Row) + Range("L" & c.Row)
        Contract = Range("E" & c.Row)
        Object = Range("F" & c.Row)
        ExecPercent = Range("I" & c.Row)
        EndDate = Range("H" & c.Row)
        strHTML = strHTML & "<p><strong>NOTE</strong></p>"
        strHTML = strHTML & "<p>We inform you that the contract n.&ordm; " & Contract & "with the object" & Object & " has reached <strong>" & ExecPercent & "</strong> of the execution period, and is expected to expire at" & EndDate & " </p>"
             
        Set oApp = CreateObject("Outlook.Application")
        Set oMail = oApp.CreateItem(0)
    
        With oMail
            .Display
            .To = SendToName
            .Subject = theSubject
            .cc = Sendtocc
            .HTMLBody = strHTML
           
    
        .Display
        '.Send
        
        End With
    
    Next c
    
    End Sub

    I appreciate your help.

    Friday, November 11, 2022 11:36 AM