View Single Post
 
Old 12-18-2015, 04:35 AM
jc491's Avatar
jc491 jc491 is offline Windows 10 Office 2016
VBA Novice
 
Join Date: Sep 2015
Location: UK
Posts: 55
jc491 is on a distinguished road
Default

Hi Paul,

thank you for responding.

Yipee! The awesome magic is working!

Very Elegant - thank you!
I was really struggling managing and running that many macros. Always misplacing them from document to document.

This way I can easily edit the styles needed per set of document templates and bulk replace all the words in one go and streamline everything.

I am really grateful for this macro. One major less stress.

I also wanted to explain the reason why I thought I may use the VBA case situation. I am going to adapt this macro to help me insert placeholders later, to the text we have just styled.

The reason I didn't state this earlier is because one set of documents just need this as it is - so this is perfect.

Later I will create a copy of this set of documents and insert placeholders.

I really hope you don't think its an imposition - which it is - but I've been fiddling about all morning hoping to showcase my adaptation - nothing works

If you wouldn't mind helping me adapt this macro - the final piece of the puzzle.

Or if I open a new thread the title would be - Find Style - Apply Placeholder before and after each style.


Code:
Sub InsertPlaceholders()

'Find a Style - Apply Placeholder before and after

Application.ScreenUpdating = False
Dim StrFnd As String, StrSty As String, i As Long

StrStyleFind = "Strong,italic,Heading 1,Heading 2,Heading 3"


With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Format = True
  .Wrap = wdFindContinue
  .MatchWildcards = True
  
  
  Case (Strong)
  
  Selection.Find.Style = ActiveDocument.Styles("Strong")
  Selection.Find.Replacement.ClearFormatting
  With Selection.Find
    .Text = ""
    .Replacement.Text = "Placeholder1^& Placeholder2"
  
  
  Case (Italic)
  
  Selection.Find.Style = ActiveDocument.Styles("italic")
  Selection.Find.Replacement.ClearFormatting
  With Selection.Find
    .Text = ""
    .Replacement.Text = "Placeholder3^& Placeholder4"
  
  
  
    .Execute Replace:=wdReplaceAll
  Next
End With
Application.ScreenUpdating = True



End Sub

Your coding eyes and expertise really appreciated.

As always forever grateful

thank you

J
Reply With Quote