Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 06-21-2021, 12:43 AM
Shelley Lou Shelley Lou is offline VBA code help: replacing punctuation Windows 10 VBA code help: replacing punctuation Office 2016
Expert
VBA code help: replacing punctuation
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA code help: replacing punctuation

Hi Macropod, many thanks for updating this code for me, very much appreciated. There appears to be 2 message boxes that come up and it won't let me run the macro - MsgBox Chr(34) & .Text & Char(34), how can I amend these so I don't get the message box. Thanks.

Image.JPG


Code:
'Remove punctuation and insert semi-colon at end of sentence
    .Find.Text = "[! ^13]@[!.\!\?:;]^13"
    Do While .Find.Execute = True
      With .Duplicate
        MsgBox Chr(34) & .Text & Chr(34)
        Select Case Trim(.Words.First)
          Case "and", "but", "or", "then"
            'do nothing
          Case Else
          .Words.First.InsertAfter ";"
        End Select
      End With
      .Collapse wdCollapseEnd
    Loop
  End With
  'Remove placeholder.
  .Paragraphs(1).Range.Delete
  With .Range
    'Prefix designated bold first words with a tab
    .Find.Text = "^13[A-Za-z]"
    Do While .Find.Execute = True
        MsgBox Chr(34) & .Text & Chr(34)
      With .Duplicate.Paragraphs.Last.Range
        If .Style = "Normal" Then
          If .Characters.First.Font.Bold = False Then .InsertBefore vbTab
        End If
      End With
      .Collapse wdCollapseEnd
    Loop
  End With
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code help: replacing punctuation How to delete all the punctuation marks from a paragraph? Jamal NUMAN Word 3 02-26-2019 02:33 PM
VBA code help: replacing punctuation punctuation order fariz Word 2 10-31-2016 12:57 AM
VBA code help: replacing punctuation Need help with modifying a replacing font VBA code- similar task but subtle change kissingfrogs2003 Word VBA 3 08-30-2016 11:42 AM
Replacing punctuation marks with footnotes nufc89 Word 2 05-22-2015 03:15 PM
Punctuation lexsper Word 0 04-06-2015 07:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:46 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