![]() |
#1
|
|||
|
|||
![]()
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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
ActiveDocument.ContentControls(ID) not working | Tejas.T | Word VBA | 3 | 03-09-2015 06:50 PM |
![]() |
BrunoChirelli | Word | 2 | 02-19-2015 12:03 PM |
wordapp.ActiveDocument.SaveAs Not Working | KSReynolds | Mail Merge | 1 | 07-18-2014 04:03 PM |
![]() |
Singh_Edm | Word | 2 | 01-20-2014 12:51 AM |
![]() |
Vivi | Word VBA | 1 | 01-27-2010 07:03 AM |