Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select a word in an cell
Make it in a sub and pass the requirements as arguments.
e.g. Private Sub CommandButton1_Click() Call HiLiteWord(ActiveCell, Range("A1").Value) End Sub Private Sub HiLiteWord(argRange As Range, argWord As String) Dim StartPos As Long With argRange StartPos = InStr(1, .Value, argWord) If StartPos = 0 Then MsgBox Chr(34) & argWord & Chr(34) & " was not found in cell " & argRange.Address Exit Sub End If .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(argWord) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi NIck, Thanks for your reply. The codes work like a charm. But I think it is useful only when you know what word to find or grab, is it? Right now I'm developing a thesaurus for excel and (supposedly) it can find synonym(s) for any word that I have selected. In your codes, you have define which word should be search for. And I dont have any clue how to modified those code to make it get any word at any cell in Excel. Westman "NickHK" wrote: AFAIK, the only way in VBA is with SendKeys: Private Sub CommandButton1_Click() Dim StartPos As Long Const WordToHiLite As String = "eat" Const RangeToSearch As String = "B6" With Range(RangeToSearch) StartPos = InStr(1, .Value, WordToHiLite) If StartPos = 0 Then Exit Sub .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(WordToHiLite) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi, I'm facing a problem in developing my excell addin. How do I select just one word from a sentences in a single cell? For example:- I like to eat fried chicken. -- This sentence is in a cell. Right now, I just want to select word "eat" from the above sentence. Is this posible? If posible, how do I accomplish that? Regards, Westman |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select a word in an cell
Hi Nick,
Thanks again for the codes. FYI, i'm using VSTO2005 SE. So, I have to modify the codes first before it can be used. By the way, from your code, isn't the argument ActiveCell and Range("A1").Value) will have the same value? If yes, when do the codes return just the selected word? Regards, Westman "NickHK" wrote: Make it in a sub and pass the requirements as arguments. e.g. Private Sub CommandButton1_Click() Call HiLiteWord(ActiveCell, Range("A1").Value) End Sub Private Sub HiLiteWord(argRange As Range, argWord As String) Dim StartPos As Long With argRange StartPos = InStr(1, .Value, argWord) If StartPos = 0 Then MsgBox Chr(34) & argWord & Chr(34) & " was not found in cell " & argRange.Address Exit Sub End If .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(argWord) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi NIck, Thanks for your reply. The codes work like a charm. But I think it is useful only when you know what word to find or grab, is it? Right now I'm developing a thesaurus for excel and (supposedly) it can find synonym(s) for any word that I have selected. In your codes, you have define which word should be search for. And I dont have any clue how to modified those code to make it get any word at any cell in Excel. Westman "NickHK" wrote: AFAIK, the only way in VBA is with SendKeys: Private Sub CommandButton1_Click() Dim StartPos As Long Const WordToHiLite As String = "eat" Const RangeToSearch As String = "B6" With Range(RangeToSearch) StartPos = InStr(1, .Value, WordToHiLite) If StartPos = 0 Then Exit Sub .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(WordToHiLite) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi, I'm facing a problem in developing my excell addin. How do I select just one word from a sentences in a single cell? For example:- I like to eat fried chicken. -- This sentence is in a cell. Right now, I just want to select word "eat" from the above sentence. Is this posible? If posible, how do I accomplish that? Regards, Westman |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select a word in an cell
Only if A1 is selected.
And it does not return the selected word; it selects the word in A1 if it is present in the ActiveCell. NickHK "Westman" wrote in message ... Hi Nick, Thanks again for the codes. FYI, i'm using VSTO2005 SE. So, I have to modify the codes first before it can be used. By the way, from your code, isn't the argument ActiveCell and Range("A1").Value) will have the same value? If yes, when do the codes return just the selected word? Regards, Westman "NickHK" wrote: Make it in a sub and pass the requirements as arguments. e.g. Private Sub CommandButton1_Click() Call HiLiteWord(ActiveCell, Range("A1").Value) End Sub Private Sub HiLiteWord(argRange As Range, argWord As String) Dim StartPos As Long With argRange StartPos = InStr(1, .Value, argWord) If StartPos = 0 Then MsgBox Chr(34) & argWord & Chr(34) & " was not found in cell " & argRange.Address Exit Sub End If .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(argWord) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi NIck, Thanks for your reply. The codes work like a charm. But I think it is useful only when you know what word to find or grab, is it? Right now I'm developing a thesaurus for excel and (supposedly) it can find synonym(s) for any word that I have selected. In your codes, you have define which word should be search for. And I dont have any clue how to modified those code to make it get any word at any cell in Excel. Westman "NickHK" wrote: AFAIK, the only way in VBA is with SendKeys: Private Sub CommandButton1_Click() Dim StartPos As Long Const WordToHiLite As String = "eat" Const RangeToSearch As String = "B6" With Range(RangeToSearch) StartPos = InStr(1, .Value, WordToHiLite) If StartPos = 0 Then Exit Sub .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(WordToHiLite) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi, I'm facing a problem in developing my excell addin. How do I select just one word from a sentences in a single cell? For example:- I like to eat fried chicken. -- This sentence is in a cell. Right now, I just want to select word "eat" from the above sentence. Is this posible? If posible, how do I accomplish that? Regards, Westman |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select a word in an cell
Since he says he is building a Thesaurus, I believe he wants the user to
select a sentence in a cell, then somehow fire his thesaurus addin which will find equivalent words to the selected word. So he wants to discover what word in a cell is selected. Kind the opposite of what you are offering. -- Regards, Tom Ogilvy "NickHK" wrote in message ... Only if A1 is selected. And it does not return the selected word; it selects the word in A1 if it is present in the ActiveCell. NickHK "Westman" wrote in message ... Hi Nick, Thanks again for the codes. FYI, i'm using VSTO2005 SE. So, I have to modify the codes first before it can be used. By the way, from your code, isn't the argument ActiveCell and Range("A1").Value) will have the same value? If yes, when do the codes return just the selected word? Regards, Westman "NickHK" wrote: Make it in a sub and pass the requirements as arguments. e.g. Private Sub CommandButton1_Click() Call HiLiteWord(ActiveCell, Range("A1").Value) End Sub Private Sub HiLiteWord(argRange As Range, argWord As String) Dim StartPos As Long With argRange StartPos = InStr(1, .Value, argWord) If StartPos = 0 Then MsgBox Chr(34) & argWord & Chr(34) & " was not found in cell " & argRange.Address Exit Sub End If .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(argWord) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi NIck, Thanks for your reply. The codes work like a charm. But I think it is useful only when you know what word to find or grab, is it? Right now I'm developing a thesaurus for excel and (supposedly) it can find synonym(s) for any word that I have selected. In your codes, you have define which word should be search for. And I dont have any clue how to modified those code to make it get any word at any cell in Excel. Westman "NickHK" wrote: AFAIK, the only way in VBA is with SendKeys: Private Sub CommandButton1_Click() Dim StartPos As Long Const WordToHiLite As String = "eat" Const RangeToSearch As String = "B6" With Range(RangeToSearch) StartPos = InStr(1, .Value, WordToHiLite) If StartPos = 0 Then Exit Sub .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(WordToHiLite) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi, I'm facing a problem in developing my excell addin. How do I select just one word from a sentences in a single cell? For example:- I like to eat fried chicken. -- This sentence is in a cell. Right now, I just want to select word "eat" from the above sentence. Is this posible? If posible, how do I accomplish that? Regards, Westman |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select a word in an cell
Hi Tom,
Yes, that is exactly what I'm looking for. Just selecting one word only and then called the thesaurus. I'm still working on the solution for it and I have tried to modify the code given by Nick but still could not get the true result. Do have any idea on how to to do this? Regards, Westman "Tom Ogilvy" wrote: Since he says he is building a Thesaurus, I believe he wants the user to select a sentence in a cell, then somehow fire his thesaurus addin which will find equivalent words to the selected word. So he wants to discover what word in a cell is selected. Kind the opposite of what you are offering. -- Regards, Tom Ogilvy "NickHK" wrote in message ... Only if A1 is selected. And it does not return the selected word; it selects the word in A1 if it is present in the ActiveCell. NickHK "Westman" wrote in message ... Hi Nick, Thanks again for the codes. FYI, i'm using VSTO2005 SE. So, I have to modify the codes first before it can be used. By the way, from your code, isn't the argument ActiveCell and Range("A1").Value) will have the same value? If yes, when do the codes return just the selected word? Regards, Westman "NickHK" wrote: Make it in a sub and pass the requirements as arguments. e.g. Private Sub CommandButton1_Click() Call HiLiteWord(ActiveCell, Range("A1").Value) End Sub Private Sub HiLiteWord(argRange As Range, argWord As String) Dim StartPos As Long With argRange StartPos = InStr(1, .Value, argWord) If StartPos = 0 Then MsgBox Chr(34) & argWord & Chr(34) & " was not found in cell " & argRange.Address Exit Sub End If .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(argWord) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi NIck, Thanks for your reply. The codes work like a charm. But I think it is useful only when you know what word to find or grab, is it? Right now I'm developing a thesaurus for excel and (supposedly) it can find synonym(s) for any word that I have selected. In your codes, you have define which word should be search for. And I dont have any clue how to modified those code to make it get any word at any cell in Excel. Westman "NickHK" wrote: AFAIK, the only way in VBA is with SendKeys: Private Sub CommandButton1_Click() Dim StartPos As Long Const WordToHiLite As String = "eat" Const RangeToSearch As String = "B6" With Range(RangeToSearch) StartPos = InStr(1, .Value, WordToHiLite) If StartPos = 0 Then Exit Sub .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(WordToHiLite) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi, I'm facing a problem in developing my excell addin. How do I select just one word from a sentences in a single cell? For example:- I like to eat fried chicken. -- This sentence is in a cell. Right now, I just want to select word "eat" from the above sentence. Is this posible? If posible, how do I accomplish that? Regards, Westman |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select a word in an cell
Tom,
I was going from the initial of "I just want to select word "eat" from the above sentence". But now it seems it is other way as yopu describe. To the OP: In that case VBA will not help you, as it cannot run in Edit mode, when the cursor is in a cell. NickHK "Tom Ogilvy" wrote in message ... Since he says he is building a Thesaurus, I believe he wants the user to select a sentence in a cell, then somehow fire his thesaurus addin which will find equivalent words to the selected word. So he wants to discover what word in a cell is selected. Kind the opposite of what you are offering. -- Regards, Tom Ogilvy "NickHK" wrote in message ... Only if A1 is selected. And it does not return the selected word; it selects the word in A1 if it is present in the ActiveCell. NickHK "Westman" wrote in message ... Hi Nick, Thanks again for the codes. FYI, i'm using VSTO2005 SE. So, I have to modify the codes first before it can be used. By the way, from your code, isn't the argument ActiveCell and Range("A1").Value) will have the same value? If yes, when do the codes return just the selected word? Regards, Westman "NickHK" wrote: Make it in a sub and pass the requirements as arguments. e.g. Private Sub CommandButton1_Click() Call HiLiteWord(ActiveCell, Range("A1").Value) End Sub Private Sub HiLiteWord(argRange As Range, argWord As String) Dim StartPos As Long With argRange StartPos = InStr(1, .Value, argWord) If StartPos = 0 Then MsgBox Chr(34) & argWord & Chr(34) & " was not found in cell " & argRange.Address Exit Sub End If .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(argWord) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi NIck, Thanks for your reply. The codes work like a charm. But I think it is useful only when you know what word to find or grab, is it? Right now I'm developing a thesaurus for excel and (supposedly) it can find synonym(s) for any word that I have selected. In your codes, you have define which word should be search for. And I dont have any clue how to modified those code to make it get any word at any cell in Excel. Westman "NickHK" wrote: AFAIK, the only way in VBA is with SendKeys: Private Sub CommandButton1_Click() Dim StartPos As Long Const WordToHiLite As String = "eat" Const RangeToSearch As String = "B6" With Range(RangeToSearch) StartPos = InStr(1, .Value, WordToHiLite) If StartPos = 0 Then Exit Sub .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(WordToHiLite) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi, I'm facing a problem in developing my excell addin. How do I select just one word from a sentences in a single cell? For example:- I like to eat fried chicken. -- This sentence is in a cell. Right now, I just want to select word "eat" from the above sentence. Is this posible? If posible, how do I accomplish that? Regards, Westman |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select a word in an cell
For what it is worth... I've already written a "Thesaurus for Excel" program, and let me tell you, there isn't any market I can find for that type of utility. Also, it is not an easy type of program to code and I doubt worth the time required to do it. Note: it uses the last word in the cell as the initial word to display equivalents for. -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "NickHK" wrote in message Tom, I was going from the initial of "I just want to select word "eat" from the above sentence". But now it seems it is other way as yopu describe. To the OP: In that case VBA will not help you, as it cannot run in Edit mode, when the cursor is in a cell. NickHK "Tom Ogilvy" wrote in message ... Since he says he is building a Thesaurus, I believe he wants the user to select a sentence in a cell, then somehow fire his thesaurus addin which will find equivalent words to the selected word. So he wants to discover what word in a cell is selected. Kind the opposite of what you are offering. -- Regards, Tom Ogilvy "NickHK" wrote in message ... Only if A1 is selected. And it does not return the selected word; it selects the word in A1 if it is present in the ActiveCell. NickHK "Westman" wrote in message ... Hi Nick, Thanks again for the codes. FYI, i'm using VSTO2005 SE. So, I have to modify the codes first before it can be used. By the way, from your code, isn't the argument ActiveCell and Range("A1").Value) will have the same value? If yes, when do the codes return just the selected word? Regards, Westman "NickHK" wrote: Make it in a sub and pass the requirements as arguments. e.g. Private Sub CommandButton1_Click() Call HiLiteWord(ActiveCell, Range("A1").Value) End Sub Private Sub HiLiteWord(argRange As Range, argWord As String) Dim StartPos As Long With argRange StartPos = InStr(1, .Value, argWord) If StartPos = 0 Then MsgBox Chr(34) & argWord & Chr(34) & " was not found in cell " & argRange.Address Exit Sub End If .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(argWord) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi NIck, Thanks for your reply. The codes work like a charm. But I think it is useful only when you know what word to find or grab, is it? Right now I'm developing a thesaurus for excel and (supposedly) it can find synonym(s) for any word that I have selected. In your codes, you have define which word should be search for. And I dont have any clue how to modified those code to make it get any word at any cell in Excel. Westman "NickHK" wrote: AFAIK, the only way in VBA is with SendKeys: Private Sub CommandButton1_Click() Dim StartPos As Long Const WordToHiLite As String = "eat" Const RangeToSearch As String = "B6" With Range(RangeToSearch) StartPos = InStr(1, .Value, WordToHiLite) If StartPos = 0 Then Exit Sub .Select SendKeys "{F2}" SendKeys "{LEFT " & Len(.Value) - StartPos + 1 & "}" SendKeys "+{RIGHT " & Len(WordToHiLite) & "}" End With End Sub NickHK "Westman" wrote in message ... Hi, I'm facing a problem in developing my excell addin. How do I select just one word from a sentences in a single cell? For example:- I like to eat fried chicken. -- This sentence is in a cell. Right now, I just want to select word "eat" from the above sentence. Is this posible? If posible, how do I accomplish that? Regards, Westman |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I just want to select the first word... | Excel Programming | |||
Auto Word Select | Excel Discussion (Misc queries) | |||
Auto Word Select | Excel Discussion (Misc queries) | |||
Select a cell containing a word | Excel Programming | |||
Find a certain word in excel and select the cell | Excel Programming |