Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 05-25-2017, 05:18 AM
cdc99999 cdc99999 is offline Transfer Outlook TextBox Text Into Email Body Windows 7 32bit Transfer Outlook TextBox Text Into Email Body Office 2013
Novice
Transfer Outlook TextBox Text Into Email Body
 
Join Date: May 2017
Location: Canada
Posts: 7
cdc99999 is on a distinguished road
Default


Thank you Sir!

The button I was referring to was the button on the form (continue button) which doesn't work, it does not automatically get the template and open it with the data entered.

I amended the code but it still does not work. I cannot use the button and when I activate the macro from Outlook it gives me a VB error “Run-time error ‘13”: Type mismatch.

When I press “Debug: it outlines the following code line in yellow: If .Tag = 0 Then

I’m guessing the new code line needs a minor adjustment?

Cheers


I have amended the code to include the include what you mentioned, below is what I now have:

Option Explicit
Sub ReplaceFromUserForm()
Dim olItem As MailItem
Dim olEmail As Outlook.MailItem
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object
Dim i As Long, j As Long
Const sFindText As String = "#Name#|#Desc#|#Acres#|#Value#"
Dim sReplaceText As String
Dim vFind As Variant
With UserForm1
.Caption = "Complete the fields"
.CommandButton1.Caption = "Continue"
.CommandButton2.Caption = "Cancel"
.Show
If .Tag = 0 Then GoTo lbl_Exit
vFind = Split(sFindText, "|")
Set olItem = CreateItemFromTemplate("U:\Operations Centre\Email Templates\form_test.oft")
With olItem
.BodyFormat = olFormatHTML
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
.Display
For j = 0 To UBound(vFind)
Set oRng = wdDoc.Range
Select Case j
Case 0
sReplaceText = UserForm1.TextBox1.Text
Case 1
sReplaceText = UserForm1.TextBox2.Text
Case 2
sReplaceText = UserForm1.TextBox3.Text
Case 3
sReplaceText = UserForm1.TextBox4.Text
Case Else
End Select
With oRng.Find
Do While .Execute(findText:=vFind(j))
oRng.Text = sReplaceText
oRng.collapse 0
DoEvents
Loop
End With
Next j
.Display
End With
End With
Unload UserForm1
lbl_Exit:
Exit Sub
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Transfer Outlook TextBox Text Into Email Body Show attachments as text in body of email?? thewiseguy31 Outlook 1 07-21-2015 09:07 PM
Transfer Outlook TextBox Text Into Email Body move email based on text in email body megatronixs Outlook 3 02-10-2015 10:58 AM
Finding specific text within body of email Tammfran Outlook 0 03-14-2014 02:32 PM
add hyperlink in body of Outlook email ChuckDrago Word 0 06-27-2013 01:13 PM
Outlook not sending body of email sbertram Outlook 0 08-30-2012 11:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:47 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft