Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2024, 05:13 AM
capitala capitala is offline Find code is not working in some word lines Windows 7 64bit Find code is not working in some word lines Office 2003
Advanced Beginner
Find code is not working in some word lines
 
Join Date: Nov 2013
Posts: 38
capitala is on a distinguished road
Default Find code is not working in some word lines

Good day! I beg your patience:

I made a code in (word VBA) to search for the letter ':' and then do something (like Bold format)

the code is working perfect in tables. BUT in a normal text, if there's two ':' in the same line, the full line is excluded from the action.
Example:

Before Code:

Name:

Nationality:

Address: City:

ID No.:



After Code:

Name:

Nationality:


Address: City:



ID No.:



as you see, in the line starting with: Address, no effect at all



Here's the code:

Dim bWC As Boolean
Dim oRng As Word.range
Set oRng = ActiveDocument.range
With oRng.Find
.MatchWildcards = True
.Text = ":"
.Format = True
.Wrap = wdFindStop

While .Execute
oRng.Select
............
Reply With Quote
  #2  
Old 11-21-2024, 02:36 PM
Guessed's Avatar
Guessed Guessed is offline Find code is not working in some word lines Windows 10 Find code is not working in some word lines Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,163
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

Bold is a toggle command so applying it once makes things bold, applying it again makes it unbold.

Instead, apply a style which happens to be bold. Then it won't matter how many times you apply it to the same text
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 11-21-2024, 03:29 PM
macropod's Avatar
macropod macropod is offline Find code is not working in some word lines Windows 10 Find code is not working in some word lines Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,374
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Guessed View Post
Instead, apply a style which happens to be bold. Then it won't matter how many times you apply it to the same text
Which is what the built-in 'Strong' Character Style is.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 11-22-2024, 09:03 AM
capitala capitala is offline Find code is not working in some word lines Windows 7 64bit Find code is not working in some word lines Office 2003
Advanced Beginner
Find code is not working in some word lines
 
Join Date: Nov 2013
Posts: 38
capitala is on a distinguished road
Default

Thaaaaaaaaaaaaaaanks
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word VBA code unable to find Bookmark Useful Word VBA 9 07-19-2023 10:42 PM
Find code is not working in some word lines Find and Replace Code Not Working falcios Word 11 06-23-2021 12:39 AM
Find code is not working in some word lines PRINT field code in Word document not working as expected smccaffr39 Word 3 02-19-2020 02:46 PM
Find code is not working in some word lines VBA Code for Grammar Check Not Working in Word 2016 PSSMargaret Word VBA 2 06-11-2016 10:53 PM
MS Word Find and Replace not working allenglishboy Word 10 07-25-2012 08:05 AM

Other Forums: Access Forums

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