Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

visual basic creating

Forum home » Delegate support and help forum » Microsoft VBA Training and help » Visual Basic - creating a populated email

Visual Basic - creating a populated email

ResolvedVersion Standard

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("\emeaemeadataAlescoFinancial RisksBusiness OperationsPRKey Information PackGallagherAJG Advised - Wholesale.dotx")
wapp.Visible = True
ElseIf Me.OptionButton2 = True Then
Set wapp = CreateObject("Word.Application")
Set wdoc = wapp.Documents.Open("\emeaemeadataAlescoFinancial RisksBusiness OperationsPRKey Information PackGallagherAJG 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

RE: Visual Basic - creating a populated email

Hi Vicki

Please accept my sincere apologises for the delay in replying to this. Your message was posted in an archived section - which we've just run through and found this question.

Can we still support you or did you get an answer from us in a different area.


Kind regards

Richard Bailey
Microsoft Certified Trainer

STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Mon 26 Apr 2021: Automatically marked as resolved.

 

Training courses

Training information:

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.

VBA tip:

Display Text In a Msgbox On Multiple Lines

When displaying text in a MsgBox you may need to show it over multiple lines. To do this use:

vbCrLf

As in:

MsgBox "The System has detected an error." & vbCrLf & "Contact your System Administrator"

The first sentence in quotes will appear above the second in the MsgBox.

View all VBA hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.