View Single Post
 
Old 12-23-2015, 05:44 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 , I reset the 2016, however , I had an epiphany and oops, it had to be me that let down the mission to mars.

I found the problem - embarrassingly the reason I had errors, is because I had the styles - that didn't exist - I forgot - that Character Style 1 and 2 were placeholders yikesss!


As you can see hopelessly useless when it comes to VBA, I spent hours fiddling about yesterday.

So both macros A+++++ working perfectly as is, I ran them on a folder full of docs - no problemo.


Now the last problem I have - I will have to ask for your help again - otherwise I will be stuck from here to 2016.

If I simply want to find the styles and insert the placeholders, which lines do I adapt?

All the #signs have been removed as they served their purpose and have to be deleted from the documents.

I simply want to find the styles and insert placeholders before and after each style



Code:
StrStyFind = "Strong,Heading 1"

StrRep = "Placeholder1 ^& Placeholder2 ,Placeholder3 ^& Placeholder4>"


With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Format = True
  .Wrap = wdFindContinue
  .MatchWildcards = True
  
  For i = 0 To UBound(Split(StrFnd, ","))

    .Text =  Split(StrFnd, ",")(i)                       ' Stuck here
   
   .Replacement.Style = Split(StrSty, ",")(i)        'Stuck here
    .Replacement.Text = Split(StrRep, ",")(i)
    .Execute Replace:=wdReplaceAll
  Next
Its been a long year! I know, a final push in the right direction would be most appreciated.



thank you

J
Reply With Quote