VBA Code to Return Name of Word 2003 Template of Origin

  • Thread starter PegDalyPA via OfficeKB.com
  • Start date
P

PegDalyPA via OfficeKB.com

Hello!

If I'm running a macro on a document that was created from a template, is
there a way to have the macro find out the name of the original template
document and store that name in a variable?

Later in the macro, I want to base a margin change on the original template
since I'm using a single macro to do something to documents created from
various templates.

For instance, when I'm using a macro to insert a landscape section in a
document created from my "8by11 Blank.dot" (which is portrait), the new
landscape section needs a left margin of 1.5", BUT if the document was
created from the template called "8by11 Proposal.dot" (also portrait) it
should get a left margin of 2.5".

Any help would be appreciated.

Thanks!

Peg
 
J

Jean-Guy Marcil

PegDalyPA via OfficeKB.com was telling us:
PegDalyPA via OfficeKB.com nous racontait que :
Hello!

If I'm running a macro on a document that was created from a
template, is there a way to have the macro find out the name of the
original template document and store that name in a variable?

Later in the macro, I want to base a margin change on the original
template since I'm using a single macro to do something to documents
created from various templates.

For instance, when I'm using a macro to insert a landscape section in
a document created from my "8by11 Blank.dot" (which is portrait), the
new landscape section needs a left margin of 1.5", BUT if the
document was created from the template called "8by11 Proposal.dot"
(also portrait) it should get a left margin of 2.5".

Any help would be appreciated.

Have you tried:
Dim strDocTemplate As String
strDocTemplate = ActiveDocument.AttachedTemplate.Name

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
P

PegDalyPA via OfficeKB.com

Thank you! That's the 2nd time you've saved me! :)
Have a great weekend!


Jean-Guy Marcil said:
PegDalyPA via OfficeKB.com was telling us:
PegDalyPA via OfficeKB.com nous racontait que :
[quoted text clipped - 13 lines]
Any help would be appreciated.

Have you tried:
Dim strDocTemplate As String
strDocTemplate = ActiveDocument.AttachedTemplate.Name
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top