Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #13  
Old 06-22-2017, 01:53 AM
gmayor's Avatar
gmayor gmayor is offline Batch replace Header and Footer and QuickStyle Windows 10 Batch replace Header and Footer and QuickStyle Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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 ofgmayor has much to be proud of
Default

I suspect that the error is self explanatory. The styleset (non standard) is available in the document in which it worked but is not available in the other documents in which it doesn't.

Frankly I wouldn't personally use style sets for this. I would create the style(s) that I wanted in a template (or document), then use the function to copy the style(s) from the template/document to the document under process (oDoc), apply the style(s) to the range(s) (oRng) as required and then reset the range to show the style settings that you have applied.

This code below is for one style, but you can sequentially copy other named styles similarly and move the range to its new location before applying them.

Code:
Dim oSource As Document
Const strStyle As String = "AsideStyle"    'The style to copy
    'open the template with the styles to be copied to the document
    Set oSource = Documents.Open _
                  (FileName:="C:\Path\TemplateName.dot", _
                   Visible:=False)

    Application.OrganizerCopy Source:= _
                              oSource.FullName, Destination:= _
                              oDoc, _
                              Name:=strStyle, _
                              Object:=wdOrganizerObjectStyles
    With oRng    'apply the style to the range
        .Style = strStyle
        .Font.Reset
        .ParagraphFormat.Reset
    End With
__________________
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
 

Tags
macro find and replace, styles, word 2016



Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch replace Header and Footer and QuickStyle Find & Replace in Header/Footer in 1000 files amodiammmuneerk@glenmarkp Word 12 03-05-2018 03:31 AM
Batch replace Header and Footer and QuickStyle New to VBA - Find/Replace in MS Word 2010 that Searches Header/Footer mbreggs Word VBA 4 06-01-2016 08:02 AM
Batch replace Header and Footer and QuickStyle Find/replace font colour in all header/footer trillium Word VBA 4 10-20-2015 10:39 PM
Batch replace Header and Footer and QuickStyle Created VBA to Find and Replace in Body, Header and Footer with Highlighting the replacement text QA_Compliance_Advisor Word VBA 11 09-23-2014 04:40 AM
Batch replace Header and Footer and QuickStyle Find & Replace in Header/Footer PReinie Word 6 01-22-2014 06:45 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:21 PM.


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