View Single Post
 
Old 12-15-2023, 09:43 AM
RobiNew RobiNew is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Sep 2023
Posts: 200
RobiNew is on a distinguished road
Default

Many thanks, Vivka! A new problem: can you explain why the code here below doesn't work? I've tried two different (but equvalent) codes for Find, but nothing changes.
Code:
Sub InsertDiv()
  With Options
  .AutoFormatAsYouTypeReplaceQuotes = False
  End With
  Dim oRng As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
  .ClearFormatting
  .Text = "(</body>)" & Chr(13)
  '.Text = "(" & Chr(60) & "/body" & Chr(62) & ")" & Chr(13)
  .Replacement.Text = "\1" & "<div align=""center"">" & Chr(13) & "=========================================================================="
  .Forward = True
  .Wrap = wdFindStop
  .Format = False
  .MatchWildcards = True
  Execute Replace:=wdReplaceAll
  '.Execute 
  End With
  With Options
  .AutoFormatAsYouTypeReplaceQuotes = True
  End With
  End Sub
Reply With Quote