Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Thread Tools Display Modes
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: 215
mohsen.amiri is an unknown quantity at this point
Default Finding special characters

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
Old 09-21-2020, 01:13 AM
Guessed's Avatar
Guessed Guessed is offline Finding special characters Windows 10 Finding special characters Office 2016
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 2,087
Guessed is a name known to allGuessed is a name known to allGuessed is a name known to allGuessed is a name known to allGuessed is a name known to allGuessed is a name known to all

You could approach this two ways:
1. Iterate through every 'sentence' and check the value of the first three characters. eg.
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

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 - Senior Forums

All times are GMT -7. The time now is 06:42 AM.

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