Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-19-2017, 08:09 PM
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

You can of course create your own functions, but for it to work correctly with the add-in you need to follow the format set out on the web page - in particular the items commented below. Different Word versions use style sets differently, but if the recorder gives the style set name as you have it it will probably work in your version.



Code:
Function changeStyle(oDoc As Document) As Boolean
    On Error GoTo Err_Handler
    'Do Something with oDoc here. e.g.,"
    oDoc.ApplyQuickStyleSet2 ("Template")
    changeStyle = True 'the name of the function = true
lbl_Exit:
    Exit Function
Err_Handler:
    changeStyle = False 'the name of the function = false
    Err.Clear
    GoTo lbl_Exit
End Function
You can also apply individual styles to the header footer ranges (or parts of the ranges) in the original macro, but the styles should be stored in the autotext entries and so this should be unnecessary. The problem will be that you have different styles with the same names in the target documents, so you could copy the styles used in your autotexts from the normal template to the document, which can be done in the same macro or perhaps better still use unique style names for your header and footer in the autotext so there is no conflict.
__________________
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
  #2  
Old 06-19-2017, 08:29 PM
Artmax Artmax is offline Batch replace Header and Footer and QuickStyle Windows 10 Batch replace Header and Footer and QuickStyle Office 2016
Novice
Batch replace Header and Footer and QuickStyle
 
Join Date: Jun 2017
Posts: 7
Artmax is on a distinguished road
Default

Thanks.
If i wanted to combine functions ois it okay to add oDoc.ApplyQuickStyleSet2 ("Template") after the 'On Error...'?
It seems to function but I may be missing some issue that I don't know about.

EDIT: Doesn't seem to work with Batch Processing.

EDIT: Subfolder Processing doesn't seem to work for multiple folders - It only processes the first folder in the stack

eg. -
\TopFolder\Sub1\
\TopFolder\Sub2\

It processes files in TopFolder and in Sub1 but not files in Sub2.

Am I missing something?

Thanks again

Last edited by Artmax; 06-19-2017 at 09:04 PM. Reason: Added some information
Reply With Quote
  #3  
Old 06-20-2017, 03:27 PM
Artmax Artmax is offline Batch replace Header and Footer and QuickStyle Windows 10 Batch replace Header and Footer and QuickStyle Office 2016
Novice
Batch replace Header and Footer and QuickStyle
 
Join Date: Jun 2017
Posts: 7
Artmax is on a distinguished road
Default

Gmayor, or others,

Is there anyway to use your amazing machine to find fonts and replace with font rather than words only?
I know you can do this with the advanced find, but not sure how I would specify it.


Thanks again for all of your help.
Reply With Quote
Reply

Tags
macro find and replace, styles, word 2016

Thread Tools
Display Modes


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 01:06 AM.


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