Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-07-2018, 06:45 AM
John9210 John9210 is offline Macro to apply Normal dot styles Windows 7 64bit Macro to apply Normal dot styles Office 2007
Advanced Beginner
Macro to apply Normal dot styles
 
Join Date: Feb 2015
Posts: 31
John9210 is on a distinguished road
Default Macro to apply Normal dot styles


Word 2016. I'm looking for a macro that will apply Normal dot styles. I have lots of old Word documents that need updating to, and using the Organizer to import the styles every time is a time consuming process.
Reply With Quote
  #2  
Old 06-07-2018, 04:24 PM
slaycock slaycock is offline Macro to apply Normal dot styles Windows 7 64bit Macro to apply Normal dot styles Office 2016
Expert
 
Join Date: Sep 2013
Posts: 256
slaycock is on a distinguished road
Default

There is a check box on the file.option.add-ins.templates dialog box that automatically imports the attached template styles.
Reply With Quote
  #3  
Old 06-07-2018, 05:15 PM
macropod's Avatar
macropod macropod is offline Macro to apply Normal dot styles Windows 7 64bit Macro to apply Normal dot styles Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Quote:
Originally Posted by slaycock View Post
There is a check box on the file.option.add-ins.templates dialog box that automatically imports the attached template styles.
That won't add any new Styles to the documents and effectively prevents users redefining any existing Styles unless they're applied to the template also.

John9210: All you need is a macro like:
Code:
Sub UpdateDocumentStyles()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document
strDocNm = ActiveDocument.FullName
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  If strFolder & "\" & strFile <> strDocNm Then
    Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
    With wdDoc
      'Copies all styles from the attached template into the document,
      'overwriting any existing styles in the document that have the same name.
      .UpdateStyles
      'Resets all existing styles in the document to match the styles in the
      'attached template each time the document is opened.
      '.UpdateStylesOnOpen = True
      .Close SaveChanges:=True
    End With
  End If
  strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub

Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
Note the commented-out '.UpdateStylesOnOpen = True' line. If you in-comment that line, the action noted in the preceding comment will take effect, effectively preventing users redefining any existing Styles unless they're applied to the template also.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Word - Find & Apply Styles to Specific Words - Using Case Statement jc491 Word VBA 17 12-26-2015 12:25 PM
Apply styles in word table 1van Word VBA 2 11-17-2015 11:05 AM
Help - Need Macro to Apply Blur SSL PowerPoint 6 07-26-2015 08:59 AM
Paragraph space before - can styles apply it intelligently? timpani Word 7 10-23-2012 04:08 PM
Why can't I change certain styles back to normal? SuperHans Word 1 10-16-2009 03:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:38 PM.


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