Use replace function with multiple replacement substrings

  • Thread starter roots_of_culture
  • Start date

R

roots_of_culture

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(AGMessage, AGTitle) 'AGInputx are the
substrings
Case 2
AGInput2 = InputBox(AGMessage, AGTitle)
Case Else
ErrorMessage = "Enter atleast one agent or do not send this email"
End Select
Next a



Set NewMail = objOLApp.CreateItemFromTemplate("G:\ak\shared12\Real
Time Traffic Management\Outlook\Templates\ContactedTL.oft")
NewMail.SentOnBehalfOfName = "Traffic Management"
NewMail.To = "Akarsh Shetty"
NewMail.Subject = "FOLLOW UP REQUIRED - " + AGInput1 + AGInput2 + "
require notification of change to their skill-set"
NewMail.HTMLBody = Replace(NewMail.HTMLBody, "Staff Member",
AGInput1) 'cannot figure out how to add more than 1 substring

thanks all



NewMail.Send
 
Ad

Advertisements

R

roots_of_culture

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.HTMLBody = 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(ANMessage, 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??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top