A
Amir
Hi!
I'm a newbie with Word scripting, but I know Access quite fine, and also a
bit of VBA.
I want to do the following and don't know where to start:
I want to make Word to do the following actions when I press 'F7' after I've
selected a text in the document (or any other F Key):
1. If there is no selected text, quit the script/macro/code/whatever.
2. Look at the CatDetails table in c:\database.mdb.
the CatDetails table contains two fields:
Field Name Data Type
CatID Text
CatText Text
I want the code to search CatDetails table for CatID which is equal to the
current selected text in the Word editor.
3. If there is no record which has CatID = SelectedText, then I want word
to beep and quit the code.
4. If there is a record which has CatID = SelectedText, I want the code to
automatically add the following text after the selected text:
" - Text about the Cat: " & CatText '(according to the selected CarID)
5. I want the (keyboard) cursur to move to the end of the text that was
added.
For example, if i'm editing the current line in word:
"Eddie2 is a nice ID for a cat."
and i'm selecting "Eddie2", and pressing for example F7, I want the code to
look at the CarDetails table, find that the CatText for "Eddie2" is "He is a
nice one", and change the line to:
"Eddie2 - Text about the Cat: He is a nice one is a nice ID for a cat"*
(* marks the place where I want the keyboard cursur to be when the code
ends.)
Thank you very much for your help.
I'm sorry if it's not the forum for that question, and I will be grateful if
you answer this question or tell me which forum to address it.
Regrads,
Amir.
I'm a newbie with Word scripting, but I know Access quite fine, and also a
bit of VBA.
I want to do the following and don't know where to start:
I want to make Word to do the following actions when I press 'F7' after I've
selected a text in the document (or any other F Key):
1. If there is no selected text, quit the script/macro/code/whatever.
2. Look at the CatDetails table in c:\database.mdb.
the CatDetails table contains two fields:
Field Name Data Type
CatID Text
CatText Text
I want the code to search CatDetails table for CatID which is equal to the
current selected text in the Word editor.
3. If there is no record which has CatID = SelectedText, then I want word
to beep and quit the code.
4. If there is a record which has CatID = SelectedText, I want the code to
automatically add the following text after the selected text:
" - Text about the Cat: " & CatText '(according to the selected CarID)
5. I want the (keyboard) cursur to move to the end of the text that was
added.
For example, if i'm editing the current line in word:
"Eddie2 is a nice ID for a cat."
and i'm selecting "Eddie2", and pressing for example F7, I want the code to
look at the CarDetails table, find that the CatText for "Eddie2" is "He is a
nice one", and change the line to:
"Eddie2 - Text about the Cat: He is a nice one is a nice ID for a cat"*
(* marks the place where I want the keyboard cursur to be when the code
ends.)
Thank you very much for your help.
I'm sorry if it's not the forum for that question, and I will be grateful if
you answer this question or tell me which forum to address it.
Regrads,
Amir.