View Single Post
 
Old 03-05-2020, 06:20 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

My question is: Why you're using all this VBA code to write boilerplate content to a document instead of using to create a document from a template that already contains all of that content?

With a template you don't need anything between:
Set objDoc = objWord.Documents.Add - with a template reference
and:
txtword =
(and even most of what's in txtword you can do without), or any of the:
objRange
stuff at the end of your code. Moreover, with a template, the only variables you need are:
Dim objWord As Object, objDoc As Object, txtword As String
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote