visual basic creating
Face-to-face training now available
Hide

TrustPilot

starstarstarstarstar Excellent

Forum home » Improve the forum » Visual Basic - creating a populated email

Visual Basic - creating a populated email

· High Priority · Version Standard

Tue 23 Apr 2019, 13:58 replyReply Delegate Vicki said...

Vicki has attended:
Excel VBA Introduction course

Visual Basic - creating a populated email

Hi, I have created a form which populates a word end product and want to create the same thing to populate an email. I currently have the below for my word documentation and thought I might be able to change the Word.application parts to outlook.application but that doesn't seen to work. I have created an email with bookmarks to refer to but cant' figure out how to make it work with the below. Any help would be really appreciated.

Private Sub CommandButton1_Click()
Dim wapp As Word.Application
Dim wdoc As Word.Document
If Me.OptionButton1 = True Then
Set wapp = CreateObject("Word.Application")
Set wdoc = wapp.Documents.Open("\\emea\emeadata\Alesco\Financial Risks\Business Operations\PR\Key Information Pack\Gallagher\AJG Advised - Wholesale.dotx")
wapp.Visible = True
ElseIf Me.OptionButton2 = True Then
Set wapp = CreateObject("Word.Application")
Set wdoc = wapp.Documents.Open("\\emea\emeadata\Alesco\Financial Risks\Business Operations\PR\Key Information Pack\Gallagher\AJG Advised - Retail New.dotx")
wapp.Visible = True
End If


If Me.OptionButton3 = True Then
wapp.Selection.Goto what:=wdGoToBookmark, Name:="NewRenewal"
wapp.Selection.TypeText Sheet2.Range("b15")
ElseIf Me.OptionButton4 = True Then
wapp.Selection.Goto what:=wdGoToBookmark, Name:="NewRenewal"
wapp.Selection.TypeText Sheet2.Range("b16")
End If

For upcoming training course dates see: Pricing & availability

 

Live dates & prices

 

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


TrustPilot
TrustScore 4.9 / 5       1310 reviews