string replace

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can somebody please tell me the proper code to replace inputted words?
I have a custom form where I need to replace ****** with a inputted name.

The code I have so far is:
Sub test()
InputBox ("recruitname?") <---- I'm missing something here also I guess but
I don't know what.
Set objFolder = Application.ActiveExplorer.CurrentFolder
Set objItem = _
objFolder.Items.Add("IPM.Note.Bootcamp done to GR")
objItem.Display
String.replace ("******",.......????
End Sub

The inputbox is there but how do I get the word that I fill in the inputbox
to replace the ****** in that mail (IPM.Note.Bootcamp done to GR)
 
InputBox() is a function. You need to set a variable to the value that it
returns:

strMyInput = InputBox ("recruitname?")

You can then use the text in the strMyInput variable to replace other text.

The text in the body of your message is Body or HTMLBody, depending on the
format. (It's actually a little more complicated than that, but since you
didn't give any information on the message format or your version of
Outlook, we'll keep it simple for starters.) The code to replace ******
with a inputted name would look like this:

strBody = objItem.Body
strBody = Replace(strBody, "******", strMyInput)
objItem.Body = strBody
objItem.Display
 
Thx a lot Sue,

I got that part working.

Now I made it a little bit more complicated and have created a userform
called "dialog". It contains 3 textboxes. They will have the same function as
the inputbox except from the fact that I don't need 3 inputboxes now....
How will I get them to work?
1st textbox needs to replace ******
2nd textbox needs to replace ######
3th textbow will need to replace §§§§§§

Can I do it also with the strmyinput?
 
Nm,

I got it to work with just 2 or 3 inputboxes.

I found the way to replace that *** also in other mails if they got opened
and that's what I needed!

Thanx a lot Sue! Now I learned something also. :-)
 
The basic Replace() technique is the same. The detail you need is how to get
the value from the textbox, and that will depend on whether or not the
textboxes bound to Outlook properties. Check the properties for each
control, on the Value tab. In the meantime, see
http://www.outlookcode.com/d/propsyntax.htm for info on how to work with
both Outlook property values and unbound control values.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top