Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-13-2024, 05:55 AM
vivka vivka is offline Seeking guidance on using Word macros to find and replace Arabic numbers after indent Windows 7 64bit Seeking guidance on using Word macros to find and replace Arabic numbers after indent Office 2016
Expert
 
Join Date: Jul 2023
Posts: 302
vivka is on a distinguished road
Default

Hi, again! If you don't mind here are some comments to your previous post.
1) If the cursor (aka selection or insertion point) is within a word (in our case a digit) that wd is considered selected. 'Within', besides within proper, also inlcudes the positions immediately before and after the word, What is more: 'within' also includes the word's trailing space! In other words, if the cursor is placed immediately before or on, or immediately after the word, or immediately after the word's trailing space, the word is treated as selected. That's why your digit becomes replaced. A rule of a thumb I use: if I want to make sure what the word is, I just double-click on it (use this technique to get surprised). If the word is followed by space, that space is also selected. Other punctuation signs do not belong to the previous word, they are individual words.


2) If you have error 5941 ("Requested Member of the Collection Does Not Exist"), most likely there's a paragraph break/empty paragraph in the selected range, which 'confuses' the code. In this case, I'd suggest adding another condition
Code:
If Len(oPar.range) > 1 Then
right after
Code:
For Each oPar In oRng.Paragraphs
and, of course, adding
Code:
End If
before
Code:
Next oPar
3) I prefer using Selection to ActiveDocument, that's why I used Selection in the code, although you intended to work on the whole document. My reason is simple: ActiveDocument may be too much of a good thing when there's no need to change the whole document. At the same time, selection can be extended to the whole document, if need be, by pressing Ctrl+A with your left hand. As you see, for me Selection is more practical. It's only my opinion.

I hope the above tips/explanations will help and even "system-specific variations" of the code execution will disappear.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Seeking guidance on using Word macros to find and replace Arabic numbers after indent Potential Clashes in Macros - Seeking Assistance yanyan9896 Word VBA 2 10-09-2023 04:59 AM
Find/replace - symbol for all numbers or symbol letters (Word 97) Genericname1111 Word 10 11-10-2019 10:37 PM
Find and Replace Numbers Macro VBA in Microsoft Word Yotem189 Word VBA 3 09-20-2018 05:55 AM
Numbers format in word to arabic Mzbarca Word 1 02-28-2016 07:56 PM
Find and replace BETWEEN numbers WordUser2015 Word 4 12-19-2014 02:09 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:46 AM.


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