Use replace function with multiple replacement substrings

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • roots_of_culture

    #1

    Use replace function with multiple replacement substrings

    Hi all,
    VB novice bear with me...
    trying to build myself a template in Outlook to make life easier

    I am aquiring multiple subtrings from the user and want to replce one
    substring in a outlook template with multiple substring... but i get
    an error!

    For a = 1 To d
    i = i + 1
    AGMessage = "Enter the name of the agent in " + TLInput + "'s team:"
    AGTitle = "Agent"
    Select Case i
    Case 1
    AGInput1 = InputBox(AGMess age, AGTitle) 'AGInputx are the
    substrings
    Case 2
    AGInput2 = InputBox(AGMess age, AGTitle)
    Case Else
    ErrorMessage = "Enter atleast one agent or do not send this email"
    End Select
    Next a



    Set NewMail = objOLApp.Create ItemFromTemplat e("G:\ak\shared 12\Real
    Time Traffic Management\Outl ook\Templates\C ontactedTL.oft" )
    NewMail.SentOnB ehalfOfName = "Traffic Management"
    NewMail.To = "Akarsh Shetty"
    NewMail.Subject = "FOLLOW UP REQUIRED - " + AGInput1 + AGInput2 + "
    require notification of change to their skill-set"
    NewMail.HTMLBod y = Replace(NewMail .HTMLBody, "Staff Member",
    AGInput1) 'cannot figure out how to add more than 1 substring

    thanks all



    NewMail.Send

  • roots_of_culture

    #2
    Re: Use replace function with multiple replacement substrings

    On Jun 5, 4:42 pm, roots_of_cultur e <akar...@gmail. comwrote:
    I am aquiring multiple subtrings from the user and want to replce one
    substring in a outlook template with multiple substring...
    >
    NewMail.Send
    Figured out the ansgwer to my own question, stupid of me to overlook
    it. I just assigned all the substrings to a master variable which i
    then used as a substring:
    l = AGInput1 + AGInput2
    NewMail.HTMLBod y = Replace(NewMail .HTMLBody, "Staff Member", l)


    On the same note of being a novice I cant figure out how to do an
    error check
    I tried writing the code below but i must have got something wrong. I
    am trying to disable the "OK" button if the user inputs a value less
    than 1.

    'prompt for number of agents
    ANMessage = "Enter the number of agents"
    ANTitle = " # of Agents"
    ANInput = InputBox(ANMess age, ANTitle)
    d = ANInput
    If d < 1 Then 'this does not work - though i
    thought it would
    cmdOK.Enabled = False
    Else
    cmdOK.Enabled = True
    End If


    ideas??

    Comment

    Working...