-
1 Attachment(s)
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
-
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..
-
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
-
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 :
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
-
Hi Rahul,
Will try it and get back to you in half hour.
-
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.
-
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
-
Sri,
Place Below Codes in NewMacros Module at the bottom...
and Assign Shortcut Key to Macro "SelectKeywordOneInstrance" ( I assigned Crtl+-)
Code:
Sub SelectNextInstanceofSameKeyword()
Dim strString As String
strString = Trim(Selection.Text)
Application.ScreenUpdating = False
Call FillListBox(strString)
Call SelectKeywordOneInstrance(strString)
Application.ScreenUpdating = True
End Sub
Code:
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
-
1 Attachment(s)
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
-
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