Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 07-28-2018, 04:20 PM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 478
jeffreybrown will become famous soon enough
Default Delete first three characters after auto numbering

I'm saving some outlines from the web which are PDFs. Once I save them in Word and apply a auto numbered outline, I get the following results.

1. 1. Marveled (v. 13a).


2. 2. Realized that Peter and John had been with Jesus (v. 13b).
3. 3. Admitted that a miracle had been performed (vv. 14-16).
4. 4. Threatened Peter and John (vv. 17-22).
a) a. Commanded them not to speak in the name of Jesus (vv. 17-18).
b) b. Peter and John said they could not but speak...(vv. 19-20).
c) c. Let them go after more threats (vv. 21-22).

How can I remove the first three characters after the auto numbering and get the results below?

1. Marveled (v. 13a).
2. Realized that Peter and John had been with Jesus (v. 13b).
3. Admitted that a miracle had been performed (vv. 14-16).
4. Threatened Peter and John (vv. 17-22).
a) Commanded them not to speak in the name of Jesus (vv. 17-18).
b) Peter and John said they could not but speak...(vv. 1920).
c) Let them go after more threats (vv. 21-22).
Reply With Quote
  #2  
Old 07-28-2018, 08:15 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 2,562
gmayor is a jewel in the roughgmayor is a jewel in the roughgmayor is a jewel in the roughgmayor is a jewel in the rough
Default

Maybe with the macro


Code:
Sub macro1()
Dim orng As Range
Dim opara As Paragraph
    For Each opara In ActiveDocument.Paragraphs
        If opara.Style Like "List*" Then
            Set orng = opara.Range
            orng.Collapse 1
            orng.MoveEndUntil Chr(32)
            orng.End = orng.End + 1
            orng.Text = ""
        End If
    Next opara
lbl_Exit:
    Set opara = Nothing
    Set orng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 07-29-2018, 05:57 AM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 478
jeffreybrown will become famous soon enough
Default

Thank you Graham. Works great.
Reply With Quote
  #4  
Old 07-29-2018, 04:45 PM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 478
jeffreybrown will become famous soon enough
Default

Hi Graham,

How can I modify this to work on a selected group of paragraphs?
Reply With Quote
  #5  
Old 07-30-2018, 12:40 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 2,562
gmayor is a jewel in the roughgmayor is a jewel in the roughgmayor is a jewel in the roughgmayor is a jewel in the rough
Default

Set a range to the selection and process the paragraphs in the range e.g.
Code:
Sub Macro2()
Dim oPara As Paragraph
Dim oRng As Range, oSel As Range
    Set oSel = Selection.Range
    For Each oPara In oSel.Paragraphs
        If oPara.Style Like "List*" Then
            Set oRng = oPara.Range
            oRng.Collapse 1
            oRng.MoveEndUntil Chr(32)
            oRng.End = oRng.End + 1
            oRng.Text = ""
        End If
    Next oPara
lbl_Exit:
    Set oPara = Nothing
    Set oRng = Nothing
    Set oSel = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #6  
Old 07-30-2018, 02:55 PM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 478
jeffreybrown will become famous soon enough
Default

Thanks again Graham. Works great.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete certain characters from a line Helend269 Word VBA 5 01-09-2018 12:08 PM
Auto numbering macro desireemm1 Word 1 12-10-2015 07:50 PM
How do I delete strange characters from a document. Stokkers Word 1 06-12-2013 04:21 AM
auto page numbering socomfort Word 2 05-28-2012 04:19 PM
Word VBA: Cannot Edit Range (Delete characters except the first in a table cell) tinfanide Word VBA 3 04-27-2012 09:48 AM


All times are GMT -7. The time now is 12:55 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft