Thread: help on this
View Single Post
 
Old 08-29-2023, 05:20 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,437
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

vivka,


I can tell that you want to learn so I don't feel like I'm poking you in your eye with what is intended to be constructive criticism.

Look at the code you posted again. Your notes state that is converts:
<S1>
<S2>
<S3>
<S4>
<S5>
To:
<S1>
<S1-S2>
<S2-S3>
<S3-S4>
<S4-S5>


When it is actually doing this:





Two problems in your code. 1) You are processing the first paragraph when you don't need to and 2) you are using smart cut and paste which is inserting unwanted spaces.


This does as your notes describes:


Code:
Sub Paras_Start_Change_1()
'Modified by GKM
Dim lngIndex 'Declare variable for indexing.
Dim oSel As Range
Dim oPar As Paragraph
Dim bSCP As Boolean 'Added variable to store user setting.
  Application.ScreenUpdating = False
  'Save user setting
  bSCP = Options.PasteSmartCutPaste
  'Turn off smart cut and paste
  Options.PasteSmartCutPaste = False
  Set oSel = Selection.Range
  'Change .Count to 1 to .Count to 2
  For lngIndex = Selection.Range.Paragraphs.Count To 2 Step -1
    Set oPar = oSel.Paragraphs(lngIndex)
    oPar.Range.Select
    With Selection
      .Collapse 1
      .MoveUp Unit:=wdParagraph, Count:=1
      .MoveRight Unit:=wdCharacter, Count:=1
      .MoveEndUntil Cset:=">"
      .Copy
      .MoveDown Unit:=wdParagraph, Count:=1
      .MoveRight Unit:=wdCharacter, Count:=1
      .PasteAndFormat (wdFormatOriginalFormatting)
      .TypeText Text:="-"
    End With
  Next lngIndex
  'Restore user setting.
  Options.PasteSmartCutPaste = bSCP
  Application.ScreenUpdating = True
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote