Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-02-2015, 12:08 PM
nbecklin nbecklin is offline ActiveDocument.Words(i).Characters.Last.Text statment not working Windows 7 64bit ActiveDocument.Words(i).Characters.Last.Text statment not working Office 2013
Novice
ActiveDocument.Words(i).Characters.Last.Text statment not working
 
Join Date: Dec 2015
Location: Iowa
Posts: 2
nbecklin is on a distinguished road
Default ActiveDocument.Words(i).Characters.Last.Text statment not working

I'm working on a text mining program to detect instances of hiatus, which is when the last letter of a word and the first letter of the next word both start with vowels. Eventually I'd like to use and/or logic to detect any vowel combinations, but I was having difficulty with the program and simplified things to figure out what was wrong. My If statement is never triggering because the ActiveDocument.Words(i).Characters.Last.Text statement doesn't seem to work. I can find vowels as the first letter of the word using ActiveDocument.Words(j).Characters.First.Text with no problems, but for some reason it can't detect them at the end of words. Here is a simplified version of the code I've been using to troubleshoot. Its only trying to look for the letter "e" at the end of words, but the if statement won't trigger. Thanks in advance for the help!



Sub hiatus()

'this bit selects the document and sets up a way to cycle through words


Dim doc As Word.Document Dim i As Integer
Dim j As Integer
Dim hiatus As Integer


'initialize counters must start on 1st and 2nd word
i = 1
j = 2
hiatus = 0


Set doc = Word.ActiveDocument


'loop through words

For i = 1 To (doc.words.Count - 1)



'this bit searches for if the word meets certain criteria


If ActiveDocument.Words(i).Characters.Last.Text = "e" Then
hiatus = hiatus + 1
End If


'increment counters
j = j + 1
Next i

doc.Range.InsertAfter "hiatus =" & (CStr(hiatus))

End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveDocument.ContentControls(ID) not working Tejas.T Word VBA 3 03-09-2015 06:50 PM
ActiveDocument.Words(i).Characters.Last.Text statment not working How show characters instead words (status bar) BrunoChirelli Word 2 02-19-2015 12:03 PM
wordapp.ActiveDocument.SaveAs Not Working KSReynolds Mail Merge 1 07-18-2014 04:03 PM
ActiveDocument.Words(i).Characters.Last.Text statment not working Color words ending with special characters Singh_Edm Word 2 01-20-2014 12:51 AM
ActiveDocument.Words(i).Characters.Last.Text statment not working Array into ComboBox + Macro-Text into ActiveDocument Vivi Word VBA 1 01-27-2010 07:03 AM

Other Forums: Access Forums

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