PDA

View Full Version : 40$ Word Macro Highlight Keywords And Maps Checklisted Words In A Listbox



Sri
07-18-2012, 10:16 PM
Hello All,

I have clearly stated my requirements in the instructions File. I am ready to pay upto 30 $ to get this work done. Thanks for your time and effort. If you need more details please let me know. Thanks !!!

Regards
Sri

https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg (https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg)
https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNsaS3Lp1 (https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNsaS3Lp1)
https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgR1EPUkhw (https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgR1EPUkhw)
https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNe_XC-jK (https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNe_XC-jK)
https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNPOdiDuv (https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNPOdiDuv)
https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgN7AC7wAc (https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgN7AC7wAc)
https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm9wlhQrYJP 3M (https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm9wlhQrYJP 3M)
https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg (https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg)
https://www.youtube.com/watch?v=DVFFApHzYVk&lc=Ugyi578yhj9zShmhuPl4AaABAg (https://www.youtube.com/watch?v=DVFFApHzYVk&lc=Ugyi578yhj9zShmhuPl4AaABAg)
https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgxvxlnuTRWiV6MUZB14AaABAg (https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgxvxlnuTRWiV6MUZB14AaABAg)
https://www.youtube.com/watch?v=_8i1fVEi5WY&lc=Ugz0ptwE5J-2CpX4Lzh4AaABAg (https://www.youtube.com/watch?v=_8i1fVEi5WY&lc=Ugz0ptwE5J-2CpX4Lzh4AaABAg)
https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxoHAw8RwR7VmyVBUt4AaABAg.9C-br0lEl8V9xI0_6pCaR9 (https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxoHAw8RwR7VmyVBUt4AaABAg.9C-br0lEl8V9xI0_6pCaR9)
https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=Ugz5DDCMqmHLeEjUU8t4AaABAg.9bl7m03Onql9xI-ar3Z0ME (https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=Ugz5DDCMqmHLeEjUU8t4AaABAg.9bl7m03Onql9xI-ar3Z0ME)
https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxYnpd9leriPmc8rPd4AaABAg.9gdrYDocLIm9xI-2ZpVF-q (https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxYnpd9leriPmc8rPd4AaABAg.9gdrYDocLIm9xI-2ZpVF-q)
https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgyjoPLjNeIAOMVH_u94AaABAg.9id_Q3FO8Lp9xHyeYSuv 1I (https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgyjoPLjNeIAOMVH_u94AaABAg.9id_Q3FO8Lp9xHyeYSuv 1I)
https://www.reddit.com/r/windowsxp/comments/pexq9q/comment/k81ybvj/?utm_source=reddit&utm_medium=web2x&context=3 (https://www.reddit.com/r/windowsxp/comments/pexq9q/comment/k81ybvj/?utm_source=reddit&utm_medium=web2x&context=3)
https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg (https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg)
https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm9wlhQrYJP 3M (https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm9wlhQrYJP 3M)
ttps://www.youtube.com/watch?v=LP9fz2DCMBE (ttps://www.youtube.com/watch?v=LP9fz2DCMBE)
https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg (https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg)
https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg.9wdo_rWgxSH9wdpcYqrv p8 (https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg.9wdo_rWgxSH9wdpcYqrv p8)
ttps://www.youtube.com/watch?v=bFxnXH4-L1A (ttps://www.youtube.com/watch?v=bFxnXH4-L1A)
https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxuODisjo6cvom7O-B4AaABAg.9w_AeS3JiK09wdi2XviwLG (https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxuODisjo6cvom7O-B4AaABAg.9w_AeS3JiK09wdi2XviwLG)
https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxBU39bTptFznDC1PJ4AaABAg (https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxBU39bTptFznDC1PJ4AaABAg)
ttps://www.youtube.com/watch?v=GqzeFYWjTxI (ttps://www.youtube.com/watch?v=GqzeFYWjTxI)
https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgwJnJDJ5JT8hFvibt14AaABAg (https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgwJnJDJ5JT8hFvibt14AaABAg)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)

Excel Fox
07-18-2012, 11:13 PM
Will have a look at this now Sri

https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg (https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg)
https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNsaS3Lp1 (https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNsaS3Lp1)
https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgR1EPUkhw (https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgR1EPUkhw)
https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNe_XC-jK (https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNe_XC-jK)
https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNPOdiDuv (https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNPOdiDuv)
https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgN7AC7wAc (https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgN7AC7wAc)
https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm9wlhQrYJP 3M (https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm9wlhQrYJP 3M)
https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg (https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg)
https://www.youtube.com/watch?v=DVFFApHzYVk&lc=Ugyi578yhj9zShmhuPl4AaABAg (https://www.youtube.com/watch?v=DVFFApHzYVk&lc=Ugyi578yhj9zShmhuPl4AaABAg)
https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgxvxlnuTRWiV6MUZB14AaABAg (https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgxvxlnuTRWiV6MUZB14AaABAg)
https://www.youtube.com/watch?v=_8i1fVEi5WY&lc=Ugz0ptwE5J-2CpX4Lzh4AaABAg (https://www.youtube.com/watch?v=_8i1fVEi5WY&lc=Ugz0ptwE5J-2CpX4Lzh4AaABAg)
https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxoHAw8RwR7VmyVBUt4AaABAg.9C-br0lEl8V9xI0_6pCaR9 (https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxoHAw8RwR7VmyVBUt4AaABAg.9C-br0lEl8V9xI0_6pCaR9)
https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=Ugz5DDCMqmHLeEjUU8t4AaABAg.9bl7m03Onql9xI-ar3Z0ME (https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=Ugz5DDCMqmHLeEjUU8t4AaABAg.9bl7m03Onql9xI-ar3Z0ME)
https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxYnpd9leriPmc8rPd4AaABAg.9gdrYDocLIm9xI-2ZpVF-q (https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxYnpd9leriPmc8rPd4AaABAg.9gdrYDocLIm9xI-2ZpVF-q)
https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgyjoPLjNeIAOMVH_u94AaABAg.9id_Q3FO8Lp9xHyeYSuv 1I (https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgyjoPLjNeIAOMVH_u94AaABAg.9id_Q3FO8Lp9xHyeYSuv 1I)
https://www.reddit.com/r/windowsxp/comments/pexq9q/comment/k81ybvj/?utm_source=reddit&utm_medium=web2x&context=3 (https://www.reddit.com/r/windowsxp/comments/pexq9q/comment/k81ybvj/?utm_source=reddit&utm_medium=web2x&context=3)
https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg (https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg)
https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm9wlhQrYJP 3M (https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm9wlhQrYJP 3M)
ttps://www.youtube.com/watch?v=LP9fz2DCMBE (ttps://www.youtube.com/watch?v=LP9fz2DCMBE)
https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg (https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg)
https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg.9wdo_rWgxSH9wdpcYqrv p8 (https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg.9wdo_rWgxSH9wdpcYqrv p8)
ttps://www.youtube.com/watch?v=bFxnXH4-L1A (ttps://www.youtube.com/watch?v=bFxnXH4-L1A)
https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxuODisjo6cvom7O-B4AaABAg.9w_AeS3JiK09wdi2XviwLG (https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxuODisjo6cvom7O-B4AaABAg.9w_AeS3JiK09wdi2XviwLG)
https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxBU39bTptFznDC1PJ4AaABAg (https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxBU39bTptFznDC1PJ4AaABAg)
ttps://www.youtube.com/watch?v=GqzeFYWjTxI (ttps://www.youtube.com/watch?v=GqzeFYWjTxI)
https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgwJnJDJ5JT8hFvibt14AaABAg (https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgwJnJDJ5JT8hFvibt14AaABAg)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)

Excel Fox
07-18-2012, 11:27 PM
Sri, so what is the purpose of the Checklist mapping? I mean all the Keywords are being highlighted in your existing word file, but none of the checklist names are being highlighted. So what is the purpose of the second list?

Sri
07-18-2012, 11:36 PM
Basically each keyword has a few properties called checklisted words. So when i click on each keyword i can view the checklisted words for that keyword. Then on any keypress event i can go from one keyword to the other in the document. I hope you understood it.

Excel Fox
07-18-2012, 11:46 PM
So the checklisted word should be highlighted in the document, and not the keyword?

Sri
07-18-2012, 11:56 PM
1. The macro would ask for an Excel file which you would select. In that file we have keywords and checklist.
2.Any keyword in the document is then highlighted. Note only highlight one occurrence of a keyword in a table.
3.This macro would run on a hot key of my choice.
4.A second macro would run on a second hot key.
5. I would select the keyword and click the hot key and in a listbox you would get the checklisted words that matched that keyword. Aside from showing the checklisted words in a listbox we are not doing anything else.
6.And a third macro would run and remove all highlighting from the document.

Sri
07-19-2012, 12:00 AM
So basically highlight all keywords at the start

When user clicks on the first keyword it shows all the checklist words that match that keyword in a listbox

Then once a hot key is pressed the cursor moves to the next keyword and displays the checklist words in a listbox

Then again hot key press it moves to the next keyword in the document and so on...

Once all the keywords are checked all the highlighting from the keywords are removed

Excel Fox
07-19-2012, 12:20 AM
OK. will get back to you by tomorrow. Will get back to you tomorrow night with a draft, and with your check on whether we are going the right way, then send a final solution.

Sri
07-19-2012, 12:36 AM
Thanks a lot .. Will wait for you to get back

Sri
07-19-2012, 11:15 PM
Hello Excel fox have you made the rough draft as yet ? Please let me know.Thanks !

Excel Fox
07-19-2012, 11:28 PM
Still working on it. A lot more complicated than anticipated.

Sri
07-19-2012, 11:55 PM
No problem. Please take your time. Thanks !

Sri
07-20-2012, 08:38 PM
Hello excel fox how far have you gotten with the code ? Please let me know

littleiitin
07-21-2012, 06:36 PM
Hi Sri,

Excel Fox is quite busy..

and He handover your work to me..

Please find the attached word macro file with solution.

Crtl+7 key is used to select mapping file and select all the keywords
Crtl+8 is used to Remove all selection
an individual keyword selection occur when select from list box.

Note: Listbox get filled once you open correct file using Crtl+7.


Please let me know if you face any issue.

Thanks
Rahul Singh

Sri
07-21-2012, 10:42 PM
Hello Rahul thanks for your work but i think my requirements have been misunderstood I shall make my requirements more clear in the next reply

Sri
07-21-2012, 10:56 PM
1. When the first macro is run it should identify all the KEYWORDS in the document using the excel file as an input.

2. Each keyword has its own dropdown listbox which populates the list of CHECKLISTED words for that keyword. For example if i click on the keyword fruit then the dropdown listbox for this keyword fruit should have apple orange grapes banana as the checklisted words. The listbox for each keyword should only populate when i click on the keyword. So for this you should match checklisted words in sheet 2 for each keyword in sheet 1 from the excel file first.

3. Then on a hot key press event i should be able to move from one keyword to the other. Upon clicking the keyword the listbox for that keyword should populate.

Note: If the same keyword repeats itself more than once in the same row then the keyword should be highlighted only once not twice. But if it occurs again in a different row then it should be highlighted.

If there are 20 highlighted words then there will be 20 listboxes. Each might contain 4, 5 .. 13 checklisted words depending on how many checklisted words are there for that keyword.

If you are still not clear please let me know. Thanks Rahul

littleiitin
07-21-2012, 11:23 PM
so sri, when all keywords will be highlighted thn how many listbox you want show.

If you want show all then where to place 20 list boxes.....?

Sri
07-21-2012, 11:37 PM
Rahul I will see the listbox with the checklisted words only for the keyword that i click. The listbox shall dropdown where the keyword occurs in the document not as a common listbox.

littleiitin
07-22-2012, 12:43 PM
Hi Sri,

Please find attached word file with asked requirement.

shortcut Keys:

Crtl+7 : To Open excel file and select all key words
Crtl+8 : To remove all the selection
Crtl+9 : To Highlight Selected keyword from document
if keyword exists then it will fill the next listbox with related checklist words

also provided a list box with all the keywords in excel file. on selection of item in this listbox it will act same as Crtl+9


Thanks
Rahul Singh

Sri
07-22-2012, 02:54 PM
I was trying to check the macro but i was not able to run it on another word document . I added three listbox 1 and listbox 12 and listbox 11 but when i run the macro it says error debug program and highlights listbox11 in the code. How do i run it on other word documents.. Cnrtl +9 only works the other shortcut keys dont seem to work.

littleiitin
07-22-2012, 03:50 PM
Sri,

Please check if macros are enable .

Second at my end every short cut key is working fine..

However if it is not working please assign shortcut keys as described in attached word doc.

Third: Please make the names ListBox1, Listbox11 and ListBox12 without spaces.

Let me know for any other issue.

Thanks
Rahul Singh

littleiitin
07-22-2012, 04:06 PM
if you want to change the name of list box just click disign mode in developer tab--> select the list box-->Press Alt+F11 -->Press F4

you can see a property window in the left pane.. in this window top property is name.. you can change its name...to desired one..

Sri
07-22-2012, 11:13 PM
I got the shortcut keys to work but the macro works only for that word document. When i try it on a different document after inserting listBox1,listBox12,listBox11 it cannot execute and gives the following error.Compile error "Method or data member not found" and highlights listbox11 in the code in line 64. If i try copy the new content of the word file into the existing sample word document then too the it cannot execute it shows an error on line 259.How do i fix it


One more issue i have is that some document where this macro needs to run are pretty long maybe 20 pages or more so can i have the listbox displayed in the page where the keyword is highlighted. Suppose its page 11 then lisbox appears in page 11. Page 6 then listbox appears in page 6

littleiitin
07-23-2012, 10:01 AM
Hi Sri,

Its Very Easy to incorporate this in other file:

Follow below steps:---

1: Open Both the File The Current File and the file where you want this macros to run.

2: Useing Developer Tab add three ListBoxes in your New File.

3: Press Alt+F11 and then F4.
You can see a "Properties-ThisDocument" window in left hand Side
In this you can see a dropdown on the top- Select First ListBox and check if its Name is ListBox1 in the Same way Second List box Name would Be ListBox12, and Third one ListBox11

4: Double Click ThisDocument of New File and Paste Below Code :



Private Sub ListBox1_Change()

Dim lngcnt As Long

For lngcnt = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(lngcnt) Then
Call RemoveAll
Call FillListBox(ListBox1.List(lngcnt))
Call SelectKeyword(ListBox1.List(lngcnt))
End If
Next
End Sub



5: Then from Previous file Drag and drop below modules in new File:
(i):-modFilePicker
(ii):-modFillListBox
(ii):-NewMacros

Note: Don't Change Any Name

6: Then Assign shortcut Keys: to
Crtl+7 to SelectAllKeywords
Crtl+8 to SelectonSelection
Crtl+9 to RemoveAll

7: Save your file as macro enabled file.



Rest Placing Listbox at fist find location has some issues and also it was not the part of specification.


Thanks
Rahul Kumar Singh

Sri
07-23-2012, 11:18 AM
Hi Rahul,

Will try it and get back to you in half hour.

Sri
07-23-2012, 12:33 PM
Hello Rahul

I was able to get the macro to execute but when i input the excel file and run Cntrl+7, I am getting an error in line 95 "Selection.Font.Color = wdColorGreen". It shows "Run time error 4605 this method or property is not available because the current selection is locked for format change". What should I do to get it working. Please let me know.

Sri
07-23-2012, 01:13 PM
Hello Rahul ,

I tried it for another document and it worked. I don't know why it din't execute for the other document and showed an error as mentioned in the previous post. I have a few issues though.

Firstly there are many occurrences of the same keyword in the document so I have to be able to navigate from occurrence to the other on a keypress I had mentioned it before too but this has been overlooked.For example if the macro executes for the keyword "country" then the keyword occurs in so many places within the document. Say it occurs twice in page 1 five times in page 2 and so on. I have to be able to navigate through each occurrence on a hotkey press. Please look into this


Secondly can I have the display of the listbox12 in each page depending on the number of pages of the document. Or is it easier to move listbox12 to whichever keyword location I am in. Suppose I am navigating for the keyword country and I am in page 10 of the document then the listbox12 is also displayed in page 10. Next on hotkey press it spots the next occurrence of the keyword country and moves to page 12 then the listbox12 also is moved to page 12.

Please let me know Thank you for your time and effort.

Regards,
Sri

littleiitin
07-24-2012, 09:48 AM
Sri,

Place Below Codes in NewMacros Module at the bottom...

and Assign Shortcut Key to Macro "SelectKeywordOneInstrance" ( I assigned Crtl+-)


Sub SelectNextInstanceofSameKeyword()

Dim strString As String

strString = Trim(Selection.Text)
Application.ScreenUpdating = False
Call FillListBox(strString)
Call SelectKeywordOneInstrance(strString)
Application.ScreenUpdating = True
End Sub




Sub SelectKeywordOneInstrance(strKey As String)
Dim objExcel As Object
Dim wbkExcel As Object
Dim wksAct As Object
Dim rngWhole As Object
Dim rngCell As Object
Dim strSearch As String
Dim rngRange As Range
Dim lngRowN As Long
Dim lngcolN As Long
Dim rngVar As Range
Dim lngCheck As Long
Dim tblTable As Table
Dim lngTblID As Long
Dim lngRow_1 As Long
Dim lngcol_1 As Long
Dim lngTableCre_1 As Double
Dim lngTableFlag_1 As Long

Set rngRange = ActiveDocument.Range
For Each tblTable In ActiveDocument.Tables
lngTblID = lngTblID + 1
tblTable.ID = lngTblID
Next
If strKey = "" Then
MsgBox "No Keyword Selected.", vbInformation, "Exit:"
Exit Sub
End If
Do
Selection.Find.ClearFormatting
Selection.Find.Text = strKey
strSearch = strKey
lngcol_1 = Selection.Tables.Parent.Cells(1).ColumnIndex
lngRow_1 = Selection.Tables.Parent.Cells(1).RowIndex
lngTableCre_1 = Selection.Tables(1).ID
Selection.Find.Execute

If Selection.Information(wdWithInTable) = True Then
If Selection.Tables(1).ID <> lngTableCre_1 Or (Selection.Tables.Parent.Cells(1).ColumnIndex <> lngcol_1 Or Selection.Tables.Parent.Cells(1).RowIndex <> lngRow_1) Then
Exit Sub
End If
End If

Loop While Selection.Find.Found

End Sub



And For List box to move: I Suggest to Place ListBox12 into Header Section.

Thanks
Rahul Kumar Singh

littleiitin
07-25-2012, 07:23 PM
Sri,

Please find the attached file. With All your Requirements...

Please Drag n drop all the modules and forms and also copy the code from thisdocument to your files thisdocument.

I have assigned Hot keys
Crtl+7 to "SelectAllKeywords" procedure which will provide you option to select mapping file and then it will highlight all the Keywords (one instance for one cell) present in mapping file.

Crtl+0 to "ShowCheckListForm" which will show you related Checklist Items of selected keyword.

Crtl+= to "SelectNextKeyword" this will select Next keyword. Let say you have selected "Country" keyword and if in list "Animal" is the next keyword then it will select the next occurrence of Animal.

Crtl+- to "SelectNextInstanceofSameKeyword" this will select Next occurrence of same keyword. Let say you have selected "Country" keyword then it will select next occurance of "Country" keyword.

Crtl+9 to "SelectonSelection" procedure which will remove all the selection and select only occurrence of selected keyword. Like if you selected "Country" then it will remove all selection and will show you all occurances of country.

Crtl+8 to "Remove All" this will remove all Highlighted keywords.


I believe this serves all your requirement.


Thanks
Rahul Singh

littleiitin
07-25-2012, 07:30 PM
Please don't delete the listboxes...

You will not be able to see because I am making their size small but they are used in code so keep them as it is.


Thanks
Rahul Kumar Singh

littleiitin
07-27-2012, 12:26 PM
Sri Please find The code for Moving from One Keyword to other: I have assigned a Hot Key Crtl+6

Just Add a module and place this code:






Sub CheckMove()

Dim lngStart As Long
Do
lngStart = Selection.Start
Selection.Move unit:=wdWord
Selection.MoveRight unit:=wdWord, Extend:=wdExtend
If Selection.Bookmarks.Exists("\EndOfDoc") = True Then
Selection.GoTo what:=wdGoToLine, which:=wdGoToFirst, Count:=1, Name:=""
End If
If Selection.Font.Color = wdColorGreen And Selection.Range.HighlightColorIndex = wdYellow Then
Exit Sub
End If

Loop

End Sub



Regarding the error: either your file is readonly or you don't have write permission.
Or some time it get locked.. So I have suggestion Just Move your Text In the file where code is running fine...



Thanks
Rahul Kumar Singh

Sri
07-27-2012, 12:44 PM
Hello Rahul,

The macro seems to work fine when its in compatibility mode taht si when i save it as a word 97-2003 document.But then I use word 2010 so the code fails to run in that case and i get runtime error 4605 format issues. I have some process controls in the document so i have to maintain the docx format. So i am in a fix as to what i should do.

I see that you have posted a function to move from one keyword to the other, But what can i do about unwanted searches like if the keyword is DA and RA the search highlights unwanted results like a"da"pation and t"ra"nsmission. Can you please fix this. My previous post i have explained this problem more clearly. Please look into it

Regards,
Sri

Sri
07-27-2012, 12:45 PM
The problem is that i have some process controls for date document version etc in my word document which is a docx file and hence when i execute i get the error. What can be done so that it works on docx files too without the runtime error. Please let me know if there a way out. ANd also kindly look into the unwante keywords being a part of the string also being highlighted. Like DA keyword a"da"ptation gets highlighted which is unnecessary. Probably you can check for space after keyword that.way keywords which occur as a part of the word can get eliminated. Thanks a ton !

littleiitin
07-27-2012, 01:37 PM
Sri Save File as Macro enabled file.. Its Extension is .docm and docx

In previous file I have provided solution to highlight only complete word and not part of the word.

Please Use Below Code iN place of Previous One:



Sub CheckMove()

Dim lngStart As Long
Dim lngCntFlag As Long

Application.ScreenUpdating = False
Do
If lngCntFlag <> 2 Then
lngStart = Selection.Start
Selection.Move unit:=wdWord
Selection.MoveRight unit:=wdWord, Extend:=wdExtend
If Selection.Bookmarks.Exists("\EndOfDoc") = True Then
lngCntFlag = lngCntFlag + 1
Selection.GoTo what:=wdGoToLine, which:=wdGoToFirst, Count:=1, Name:=""
End If
If Selection.Font.Color = wdColorGreen And Selection.Range.HighlightColorIndex = wdYellow Then
Exit Sub
End If
Else
Selection.GoTo what:=wdGoToLine, which:=wdGoToFirst, Count:=1, Name:=""
MsgBox "There is no highlighted Keyword in file."

Exit Sub
End If

Loop
Application.ScreenUpdating = True
End Sub



Thanks
Rahul Kumar singh

littleiitin
07-27-2012, 11:51 PM
Please Replace This Code:



Sub SelectAllKeywords()

Dim objExcel As Object
Dim wbkExcel As Object
Dim wksAct As Object
Dim wksCheck As Object
Dim rngWhole As Object
Dim rngCell As Object
Dim strSearch As String
Dim rngRange As Range
Dim lngRow As Long
Dim lngcol As Long
Dim lngRowN As Long
Dim lngcolN As Long
Dim lngTableCre As Double
Dim lngTableFlag As Long
Dim strFilePath As String
Dim rngCheck As Object
Dim rngKey As Object
Dim wksNew As Object
Dim rngFin As Object
Dim lngCntr As Long
Dim tblTable As Table
Dim lngTblID As Long

Application.ScreenUpdating = False
For Each tblTable In ActiveDocument.Tables
lngTblID = lngTblID + 1
tblTable.ID = lngTblID
Next

Set objExcel = CreateObject("Excel.Application")

strFilePath = FilePicker
If strFilePath = "" Then
GoTo Xit
End If
objExcel.Visible = True
Set wbkExcel = objExcel.workbooks.Open(strFilePath)
Set wksAct = wbkExcel.worksheets("KeyWord")
Set wksCheck = wbkExcel.worksheets("Checklist")


With wksAct
Set rngKey = wksAct.Application.Intersect(.UsedRange, .UsedRange.Offset(1))
varKeywords = rngKey
Set rngWhole = rngKey.Columns(rngKey.Columns.Count)
End With
With wksCheck
Set rngCheck = wksCheck.Application.Intersect(.UsedRange, .UsedRange.Offset(1))
varCheck = rngCheck
End With
wbkExcel.Sheets.Add After:=wbkExcel.Sheets(wbkExcel.Sheets.Count)
Set wksNew = wbkExcel.activesheet
With wksNew
rngCheck.Copy .Range("A2")
' .Range("A2").PasteSpecial xlpasteall
.Range("C2").Value = "=Vlookup(A2," & rngKey.Address(, , , 1) & ",2)"
.Range("D2").Value = "=B2"
Set rngFin = .Range("C2:D" & rngCheck.Rows.Count + 1)
rngFin.filldown
With ThisDocument.ListBox11
.Clear
.ColumnCount = 2
For lngCntr = 1 To rngFin.Rows.Count - 1
.AddItem rngFin.Columns(1).Cells(lngCntr)
.List(lngCntr - 1, 1) = CStr(rngFin.Columns(2).Cells(lngCntr).Value)
Next
End With
End With
ThisDocument.ListBox11.Height = 1
ThisDocument.ListBox11.Width = 1
Set rngRange = ActiveDocument.Range
Selection.GoTo what:=wdGoToLine, which:=wdGoToFirst, Count:=1, Name:=""
ThisDocument.ListBox1.Clear
ThisDocument.ListBox12.Clear
For Each rngCell In rngWhole.Cells
ThisDocument.ListBox1.AddItem rngCell.Value
Do
Selection.Find.ClearFormatting
Selection.Find.Text = rngCell.Value
Selection.Find.MatchWholeWord = True
strSearch = rngCell.Value
Selection.Find.MatchWholeWord = True
Selection.Find.Execute
If Selection.Information(wdWithInTable) = True Then
If Selection.Tables(1).ID <> lngTableCre Or (Selection.Tables.Parent.Cells(1).ColumnIndex <> lngcol Or Selection.Tables.Parent.Cells(1).RowIndex <> lngRow) Then
lngTableFlag = 0
lngcol = 0
lngRow = 0
lngTableCre = 0
End If
End If
If lngcol = 0 And lngRow = 0 And lngTableCre = 0 Then
Selection.Font.Color = wdColorGreen
Selection.Range.HighlightColorIndex = wdYellow
End If
If Selection.Information(wdWithInTable) = True Then
If Selection.Tables(1).ID <> lngTableCre Or (Selection.Tables.Parent.Cells(1).ColumnIndex <> lngcol Or Selection.Tables.Parent.Cells(1).RowIndex <> lngRow) Then
lngcol = Selection.Tables.Parent.Cells(1).ColumnIndex
lngRow = Selection.Tables.Parent.Cells(1).RowIndex
lngTableCre = Selection.Tables(1).ID
lngTableFlag = 1
End If
End If
If Selection.Information(wdWithInTable) = True Then
If Selection.Tables.Parent.Cells(1).ColumnIndex <> lngcol Or Selection.Tables.Parent.Cells(1).RowIndex <> lngRow Then
Selection.Font.Color = wdColorGreen
Selection.Range.HighlightColorIndex = wdYellow
End If
End If

Loop While Selection.Find.Found
Selection.GoTo what:=wdGoToLine, which:=wdGoToFirst, Count:=1, Name:=""

lngTableFlag = 0
lngcol = 0
lngRow = 0
lngTableCre = 0
Next
wbkExcel.Close 0
Set wbkExcel = Nothing
Xit:
objExcel.Quit
Application.ScreenUpdating = True

End Sub

littleiitin
07-28-2012, 03:11 PM
Thanks Sri,

Received money..


Thanks
Rahul Kumar Singh