![]() |
#1
|
|||
|
|||
![]()
I am trying to figure out how to create two different code that modifies text that I have copied. As background, the copied text will always have this format:
"This is the text" Citation Now sometimes there will be other quotation marks within the outer quotation marks. For instance: "This is "the" text" Citation There will be different character spacing between the closing quotation mark and the citation. Sometimes, it will be paragraph symbols, other times braking spaces, other times only one space, etc. For the first code, I am trying to do a few things:
For the second code, I am trying do everything that the first code does, but just flip how it all fits together, i.e., Citation ("This is the text"). I have a starting code, but I am having a lot of difficulties figuring out how to do the more specific things in this code. For the second code, I can't even figure out how to get it to paste correctly. Code 1: Code:
Sub Cite1() Application.ScreenUpdating = False Dim Rng As range Set Rng = Selection.range Rng.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis) With Rng .MoveStartUntil Chr(11), wdForward .End = .Start + 2 .Text = " " End With Selection.MoveStartUntil ")", wdForward Application.ScreenUpdating = True End Sub Code:
Sub Cite2() Application.ScreenUpdating = False Dim RngA As range, RngB As range, StrTmp As String Set RngA = Selection.range With RngA .Paste Do While .Characters.Last Like "[ " & Chr(11) & vbCr & "]" .End = .End - 1 Loop .InsertBefore " (" & Chr(147) Set RngB = .Duplicate With RngB .MoveStartUntil Chr(11), wdForward .End = .Start + 2 .Text = "." & Chr(148) & ") " .Collapse wdCollapseEnd .End = RngA.End End With .Collapse wdCollapseStart .FormattedText = RngB.FormattedText RngB.Text = vbNullString End With Application.ScreenUpdating = True End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
leeqiang | Excel Programming | 10 | 04-17-2022 03:30 AM |
![]() |
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 |
![]() |
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 |