Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pop-up form in Outlook, user selects values, pass values back?

Status
Not open for further replies.

may1hem

Programmer
Jul 28, 2002
262
GB
I'm creating a pop-up form to be used when replying to e-mails. I've created a new Userform and I can send data from an e-mail to the pop-up Userform, but I don't know how to send data back from the Userform to the original e-mail. Can anyone help?

Here's the code:
------------------------------
'create reference to current e-mail message.
Dim objMailItem As Outlook.MailItem
Set objMailItem = Application.ActiveInspector.CurrentItem

'Create a reference to the body content of the e-mail.
Dim myMailBody As String
myMailBody = objMailItem.Body

'load & show the pop-up Userform.
Load frmSelectReply
frmSelectReply.TextBox1.Text = myMailBody
frmSelectReply.Show
------------------------------

Now the Userform (frmSelectReply) will show up and I can make some changes to the e-mail content, including ticking various checkboxes on the Userform.

Then how can I pass these value back to the original e-mail?

Does the code go in the module for the form?

Any ideas?

May
 
One method:[ol][li]In your exisitng module (Module1?) create a Public variable in the general declarations.
Code:
Public NewMessageBody As String
[/li]
[li]Then in your form module you can set this variable in the forms' [tt]Terminate()[/tt] event:
Code:
Private Sub UserForm_Terminate()
[green]'Assumes your Public variable is in Module1[/green]
[i]Module1[/i].NewMessageBody = Me.TextBox1.Value
End Sub
[/li]
[li]Then you can return [tt]NewMessageBody[/tt] back to [tt]objMailItem[/tt]
Code:
objMailItem.Body = NewMessageBody
[/li][/ol]

Hope this helps,
CMP


(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top