We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Outlook Reply Form

S B
S B asked
on
Medium Priority
781 Views
Last Modified: 2010-08-05
Can someone tell me how to create a macro called RFP (Request for Projector) that when executed will enter text into the comment field of a reply form so that all I have to do is click on Send.  Any assistance will be greatly appreciated. My knowledge of VB is none.

Thanks in advance
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2010

Commented:
Hi Seb112860,

> enter text into the comment field of a reply form
What kind of reply form?  A message?

Cheers!
S B

Author

Commented:
A form that was created in Outlook via Tools > Forms > Design a form.
CERTIFIED EXPERT
Top Expert 2010

Commented:
I understood that.  My question was what kind of form?  Is it one based on a message, on a task, an appointment, or something else?
S B

Author

Commented:
Message.
CERTIFIED EXPERT
Top Expert 2010

Commented:
Here's the macro for doing this.  
1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expended, expand Modules and click on Module1
4.  Copy the macro and paste it into the right-hand pane of the VB editor window.
5.  Click the diskette icon on the toolbar to save the changes
6.  Close the VB Editor
7.  Click Tools->Macro->Security
8.  Change the Security Level to Medium

To use this, open a message and click reply or forward.  Now run the macro.  It'll insert your text at the top of the message.

Sub RequestForProjector()
    Dim olkMessage As Outlook.MailItem, _
        strText As String
    'Edit the text on the next line as desired.
    strText = "My standard text for Request for Projector."
    If Application.ActiveInspector.CurrentItem.Class = olMail Then
        Set olkMessage = Application.ActiveInspector.CurrentItem
        If olkMessage.BodyFormat = olFormatHTML Then
            olkMessage.HTMLBody = strText & olkMessage.HTMLBody
        Else
            olkMessage.Body = strText & olkMessage.Body
        End If
        olkMessage.Display
    End If
End Sub
S B

Author

Commented:
When I ran the macro, it didn't give me any errors but it didn't insert any text into the comments field.  Any ideas?

Thanks in advance
S B

Author

Commented:
Please accept my appologies.  When I ran the code on a regular message after clicking on reply it worked in the body of the message.  I guess the form is something other than a message.  How can I tell exactly what the form is created from?
CERTIFIED EXPERT
Top Expert 2010

Commented:
Launch the form designer (Tools->Forms->Design a Form) and select this form.  Look toward the bottom of that dialog-box and you'll see the type of form.  It'll begin with "IPM."  Go ahead and open the form in the designer and select that field.  Let me know what the field name is.
S B

Author

Commented:
It's a IPM.Note and the name of the field is TextBox1.  On the Value tab next to Choose Field it says LP Reply Comments.
CERTIFIED EXPERT
Top Expert 2010
Commented:
Ok, try this.

Sub RequestForProjector()
    Dim olkMessage As Object, _
        strText As String
    'Edit the text on the next line as desired.
    strText = "My standard text for Request for Projector."
    If Application.ActiveInspector.CurrentItem.Class = olNote Then
        Set olkMessage = Application.ActiveInspector.CurrentItem
        olkMessage.UserProperties("LP Reply Comments") = strText & olkMessage.UserProperties("LP Reply Comments")
        olkMessage.Display
    End If
End Sub

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
S B

Author

Commented:
It didn't work.  When I try it in a regular message and change olNote to olMail it works but it doesn't work when I click on reply on a form and click in the comments field and execute the macro.
CERTIFIED EXPERT
Top Expert 2010

Commented:
I can only think of two explanations.  One, the form class is not IPM.Note or two, the field name is not "LP Reply Comments".
S B

Author

Commented:
I recopied the code and changed olNote to olMail and tried again and I was pleasantly shocked when it worked.  I tried exactly what you instructed me to and it didn't work but decided to try again and the second time around it did work.

Thanks so much for all of your assistance.
CERTIFIED EXPERT
Top Expert 2010

Commented:
Excellent.  You're welcome.  Glad I could help out.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.