Replace fields in Word template with data from Excel



Replace fields in Word template with data from Excel. Create form letters from data listed in Excel
Check out my online courses www.easyexcelanswers.com/courses.html
All my courses include online support and a user manual
Let me teach you the VBA that I have learn in my five years of consulting

Let’s take the frustration out of user forms

Become an Affiliate and earn 25% on Course Sales

For more help visit my website www.easyexcelanswers.com or email me at easyexcelanswers@gmail.com.

Contact me regarding customizing this template for your needs.

Click for online Excel Consulting

I am able to provide online help on your computer at a reasonable rate.

I use a Blue condenser Microphone to record my videos, here is the link

Check out Crowdcast for creating your webinars

If you need to buy Office 2019 follow

I use Tube Buddy to help promote my videos
Check them out

Follow me on Facebook

TWEET THIS VIDEO

Follow me on twitter
easyexcelanswers

IG @barbhendersonconsulting

You can help and generate a translation to you own language

*this description may contain affiliate links. When you click them, I may receive a small commission at no extra cost to you. I only recommend products and services that I’ve used or have experience with.

templates including code are available for $50 USD

code
Sub ReplaceText()
Dim wApp As Word.Application
Dim wdoc As Word.Document
Dim custN, path As String
Dim r As Long
r = 2
Do While Sheet1.Cells(r, 1) (not equal to) “”
Set wApp = CreateObject(“Word.Application”)

wApp.Visible = True

Set wdoc = wApp.Documents.Open(Filename:=”C:UsersscreaOneDrivereconstructionBHDocumentsExcelwelcome.dotx”, ReadOnly:=True)
With wdoc
.Application.Selection.Find.Text = “||name||”
.Application.Selection.Find.Execute
.Application.Selection = Sheet1.Cells(r, 1).Value
.Application.Selection.EndOf

.Application.Selection.Find.Text = “||address||”
.Application.Selection.Find.Execute
.Application.Selection = Sheet1.Cells(r, 2).Value
.Application.Selection.EndOf

.Application.Selection.Find.Text = “||city||”
.Application.Selection.Find.Execute
.Application.Selection = Sheet1.Cells(r, 3).Value
.Application.Selection.EndOf

.Application.Selection.Find.Text = “||postal code||”
.Application.Selection.Find.Execute
.Application.Selection = Sheet1.Cells(r, 4).Value
.Application.Selection.EndOf

.Application.Selection.Find.Text = “||name||”
.Application.Selection.Find.Execute
.Application.Selection = Sheet1.Cells(r, 1).Value
.Application.Selection.EndOf

custN = Sheet1.Cells(r, 1).Value
path = “C:UsersscreaOneDriveDesktopinvoices”
.SaveAs2 Filename:=path & custN, _
FileFormat:=wdFormatXMLDocument, AddtoRecentFiles:=False
End With
r = r + 1
Loop

End Sub

Watch more new videos about Excel Office | Synthesized by Mindovermetal English

Rate this post

Bài viết liên quan

Theo dõi
Thông báo của
guest
2 Comments
Cũ nhất
Mới nhất Được bỏ phiếu nhiều nhất
Phản hồi nội tuyến
Xem tất cả bình luận
Barb Henderson

thank you for watching my video. Because I am not able to put square brackets in the description of video, I have replaced the <<field_name>> with ||field_name|| in the code in the description.

Crafty_Tams

Thanks for sharing, that’s brilliant