Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-13-2022, 10:33 PM
tanko tanko is offline For loop not moving to next paragraph Windows 10 For loop not moving to next paragraph Office 2016
Novice
For loop not moving to next paragraph
 
Join Date: Jan 2021
Posts: 17
tanko is on a distinguished road
Default For loop not moving to next paragraph


Hi all.

The code below will just not move on to the next paragraph no matter what I do. It just loops over and over on the same paragraph. What am I missing?

Code:
Private Sub secHeading()
    Dim para As Paragraph
    Dim firstword As String

    For Each para In ActiveDocument.Range.Paragraphs
        If InStr(1, para.Range.Words(1), "RCW") <> 0 Then
            With para.Range
                .Collapse (wdCollapseEnd)
                .Move Unit:=wdCharacter, Count:=-1
                .Delete
                .InsertAfter ("  --  ")
                .Style = "Heading 1"
            End With
        End If
    Next
    
End Sub
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop to Insert Comments Moving Slowly AntCTAZ Word VBA 1 11-02-2022 07:17 PM
Inserting text from a Userform into a Field in a paragraph in a paragraph in a word document storemaz Word VBA 1 03-13-2020 08:11 AM
For loop not moving to next paragraph Moving up/ down a paragraph within a Table Cell by using keyboard Joey Cheung Word Tables 1 08-12-2014 05:19 PM
For loop not moving to next paragraph Moving cell content without moving borders & shading? unittwentyfive Excel 1 10-25-2013 12:56 PM
For loop not moving to next paragraph Moving formula range multiple cells when moving sum over one cell FraserKitchell Excel 4 02-26-2010 10:38 AM

Other Forums: Access Forums

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