Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-20-2020, 10:22 PM
mohsen.amiri mohsen.amiri is offline Finding special characters Windows 8 Finding special characters Office 2013
Competent Performer
Finding special characters
 
Join Date: Aug 2014
Posts: 221
mohsen.amiri is an unknown quantity at this point
Default Finding special characters

Hello
I want to select sentences which are start by special characters (e.g. com) and 2 characters after it (e.g. compa in company, comat in comate, combe in comber).


How can I do it?
Reply With Quote
  #2  
Old 09-21-2020, 01:13 AM
Guessed's Avatar
Guessed Guessed is offline Finding special characters Windows 10 Finding special characters Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
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

You could approach this two ways:
1. Iterate through every 'sentence' and check the value of the first three characters. eg.
Code:
Sub aTest()
  Dim aSentence As Range
  For Each aSentence In ActiveDocument.Sentences
    If Left(aSentence.Text, 3) = "com" Then
      'Do something
      Debug.Print aSentence.Text
    End If
  Next aSentence
End Sub
2. Do a find in the document for instances of "com" and then check if that appears at the start of a sentence.

#1 uses Word's definition of a sentence so it is simpler but is likely to be slower.
#2 would probably be faster but you would need to work out a definition of what constitutes a Sentence.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding special characters Special keyboard characters originalsbyterry Word 12 12-25-2018 03:10 AM
Finding special characters Special characters in Word Peter Maggs Word 8 01-13-2017 02:41 PM
Search all special characters in MS word 2007 dshrish Word 3 03-28-2013 05:23 AM
Macros and special characters. oldzack Word 3 10-31-2011 04:16 AM
Special Characters missing timorrill Word 1 06-09-2009 11:34 PM

Other Forums: Access Forums

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