Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 03-22-2022, 02:56 PM
macropod's Avatar
macropod macropod is offline Code to modify text when pasting Windows 10 Code to modify text when pasting Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I don't see any conversion of:
"This is the text" Citation
to:
Citation ("This is the text")
as described in your first post.

For what is shown in the attached document:
Code:
Sub Demo()
Application.ScreenUpdating = False
With Selection.Paragraphs.First.Range.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Format = False
    .Forward = True
    .Wrap = wdFindStop
    .MatchWildcards = True
    .Text = "[“”\(\[\)\]]"
    .Replacement.Text = ""
    .Execute Replace:=wdReplaceAll
    .Text = Chr(34)
    .Replacement.Text = """"
    .Execute Replace:=wdReplaceAll
    .Text = ". . ."
    .Replacement.Text = "…"
    .Execute Replace:=wdReplaceAll
    .Text = "^s"
    .Replacement.Text = " "
    .Execute Replace:=wdReplaceAll
    .Text = "[ ]{2,}"
    .Replacement.Text = " "
    .Execute Replace:=wdReplaceAll
    .Text = "[^l^13]{1,}"
    .Replacement.Text = "  "
    .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
Note that, unlike using string manipulations, the above code retains the original formatting.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to modify text when pasting How to modify the code to meet the corresponding requirements leeqiang Excel Programming 10 04-17-2022 03:30 AM
Code to modify text when pasting how modify a macro code tarikov2006 Excel Programming 1 11-18-2016 04:10 AM
Modify right-click context menu to only allow pasting text derajlance Word VBA 0 05-24-2016 02:25 PM
Code to modify text when pasting Recovering/Removing a Password to Modify PPAM Code Steve_B PowerPoint 3 01-08-2014 01:06 PM
Modify vba code to print based on name in the InputBox OTPM Project 0 05-25-2011 02:03 AM

Other Forums: Access Forums

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