Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-24-2020, 02:57 AM
jmasiak jmasiak is offline Problem with attaching template in AutoNew sub Windows 10 Problem with attaching template in AutoNew sub Office 2019
Novice
Problem with attaching template in AutoNew sub
 
Join Date: Sep 2020
Location: Poland
Posts: 1
jmasiak is on a distinguished road
Default Problem with attaching template in AutoNew sub

Hello!
I wrote a macro to automatically attaching template in new document:


Code:
Sub AutoNew()
    ActiveDocument.AttachedTemplate = <Path To Template>
    ActiveDocument.UpdateStylesOnOpen = True
End Sub
However, this macro doesn't work properly. It attaches the template, macros in the template work, but it doesn't update styles. Only styles from the Normal template are available.
Could you tell me what can I do?
Thanks in advance
Reply With Quote
  #2  
Old 09-24-2020, 04:20 AM
gmayor's Avatar
gmayor gmayor is offline Problem with attaching template in AutoNew sub Windows 10 Problem with attaching template in AutoNew sub Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Why don't you use the template as intended and create new documents from it?
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 09-24-2020, 04:09 PM
Guessed's Avatar
Guessed Guessed is offline Problem with attaching template in AutoNew sub Windows 10 Problem with attaching template in AutoNew sub Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I agree with Graham, this macro misses a lot of template functionality and the logistics of where you would need to store the macro means you should either be modifying the Normal.dotm template styles or creating a new doc from a specific template.

UpdateStylesOnOpen does exactly that. You would need to close and reopen the document to see the effect of that instruction. If you want an instant effect with importing the AttachedTemplate styles you should use this instead.
ActiveDocument.UpdateStyles
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #4  
Old 09-24-2020, 09:50 PM
macropod's Avatar
macropod macropod is offline Problem with attaching template in AutoNew sub Windows 7 64bit Problem with attaching template in AutoNew sub Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Cross-posted at: vba - Problem with attaching template in AutoNew sub - Stack Overflow
For cross-posting etiquette, please read: Excelguru Help Site - A message to forum cross posters
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 09-25-2020, 08:07 AM
Charles Kenyon Charles Kenyon is offline Problem with attaching template in AutoNew sub Windows 10 Problem with attaching template in AutoNew sub Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

I responded in Stack Overflow. Please read the link on etiquette posted by Macropod.
Reply With Quote
Reply

Tags
autonew, styles, template

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with attaching template in AutoNew sub Macro added to Ribbon in template does not appear after attaching template rocky2 Word VBA 1 04-04-2016 12:00 AM
Attaching files Andy Curshen Outlook 0 01-21-2016 12:48 PM
Problem with attaching template in AutoNew sub Image is attaching ANH Mail Merge 1 09-30-2015 02:05 PM
Attaching a folder alamorchgirl Misc 0 06-16-2011 06:32 PM
attaching (relative,logical or virtual) path to template word document wissam Mail Merge 0 08-04-2009 05:09 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:14 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft