Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-31-2021, 09:24 PM
Bikram Bikram is offline Importing styles using Templates Windows 10 Importing styles using Templates Office 2007
Advanced Beginner
Importing styles using Templates
 
Join Date: Jul 2021
Location: Nepal
Posts: 90
Bikram is on a distinguished road
Question Importing styles using Templates

I am using a document template to import styles in a document using
Sub Macro7()
'
' Macro7 Macro
'
'
With ActiveDocument
.UpdateStylesOnOpen = True
.AttachedTemplate = _
"C:\Users\aspBikram\AppData\Roaming\Microsoft\Temp lates\Physics_Styles.dotm"
.XMLSchemaReferences.AutomaticValidation = True
.XMLSchemaReferences.AllowSaveAsXMLWithoutValidati on = False
End With


End Sub

It worked awesomely but once I finalized the files and then close it and open again to edit some texts the formatting done after importing the styles would have already reversed. I want to avoid updatestylesonopen but when I set it to false I would have to manually reapply and update each style. Here, what I want is to update styles but only once(not for each time the document is opened). Can anyone guide me on how to do that??
Reply With Quote
  #2  
Old 08-31-2021, 09:44 PM
Guessed's Avatar
Guessed Guessed is offline Importing styles using Templates Windows 10 Importing styles using Templates Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
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

Is the template the "attached template"? If so, you can just refresh styles and turn off the auto update
Code:
ActiveDocument.UpdateStylesOnOpen = False
ActiveDocument.UpdateStyles
If the template is NOT the attached template, you can use this
Code:
ActiveDocument.CopyStylesFromTemplate (sPath)   'import styles from addin template
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 08-31-2021, 10:40 PM
Bikram Bikram is offline Importing styles using Templates Windows 10 Importing styles using Templates Office 2007
Advanced Beginner
Importing styles using Templates
 
Join Date: Jul 2021
Location: Nepal
Posts: 90
Bikram is on a distinguished road
Default

That worked great!! Sir. Thank you for the reply.
Reply With Quote
Reply

Tags
importing styles



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting rid of Styles and Templates confusion John 4 Word 1 10-27-2020 07:25 AM
Using Styles in Templates to help format text - Importing and working with Templates daithy Word 2 01-03-2020 05:06 PM
Importing styles using Templates Templates and New Documents Baased on Styles Andrewmb Word 4 07-08-2012 08:16 PM
Importing styles using Templates Importing Styles causing odd formatting problems. Red Pill Word 3 06-12-2012 06:19 AM
Importing styles using Templates Importing Templates in Word 2007 rbilleaud Word 4 06-29-2011 05:51 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:56 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