Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2024, 07:26 PM
capitala capitala is offline Q: vba code to move from the first paragraph to next Windows 7 64bit Q: vba code to move from the first paragraph to next Office 2003
Advanced Beginner
Q: vba code to move from the first paragraph to next
 
Join Date: Nov 2013
Posts: 34
capitala is on a distinguished road
Default Q: vba code to move from the first paragraph to next

For some reason, I need a vba code (word 2013) that
1) Moves first to the first paragraph
2) Selects the text in that paragraph
3) Do an event.

Afterwards, it should move to the next paragraph .....etc. till the last paragraph.

I've tried this code:

Dim wdoc As Document
Dim Para As Paragraph
Set wdoc = ActiveDocument
For Each Para In wdoc.Paragraphs
do.....


Next Para

But it doesn't move to the next paragraph.

Thanks in advance
Reply With Quote
  #2  
Old 04-01-2024, 10:03 PM
Guessed's Avatar
Guessed Guessed is online now Q: vba code to move from the first paragraph to next Windows 10 Q: vba code to move from the first paragraph to next Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,981
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

The logic is OK if your 'event' doesn't remove the Para. However it sounds like you are doing exactly that. Normally, we get around this by working backwards through a collection.
See this thread for an approach that might work better https://www.msofficeforums.com/word-...paragraph.html
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Q: vba code to move from the first paragraph to next Applying a VBA code to current paragraph without being selected laith93 Word VBA 6 10-14-2022 11:10 PM
Q: vba code to move from the first paragraph to next Help with a logical code, end of paragraph lines Cendrinne Word VBA 9 06-11-2021 09:39 PM
Q: vba code to move from the first paragraph to next Top of my VBA code window is hidden and I can't seem to move it mrsjetset Word VBA 1 06-26-2016 07:41 AM
Find Bookmark, move to bookmark, execute code, repeat raymm3852 Word VBA 10 04-15-2016 06:21 PM
Q: vba code to move from the first paragraph to next Get para no where txt is found, and move text to end of paragraph using Word 201 marceepoo Word VBA 2 12-20-2012 11:42 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:04 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft