Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
Here's what I need to do. I need to create a macro that opens a list that
the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. Once the user chooses that person, it drops in the signautre block for that particular person from their autotext entry. Is this possible? And if so, can someone steer me in the right direction? |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
Have you considered using an AUTOTEXTLIST field? See
http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. Once the user chooses that person, it drops in the signautre block for that particular person from their autotext entry. Is this possible? And if so, can someone steer me in the right direction? |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
I thought about using the AUTOTEXTLIST but that won't work as the documents
are different each time, and therefore won't have the prompt or trigger where they will right click to open the list. I don't want them to have to type in a word to right click on just to bring up that list where they want the signature. "Stefan Blom" wrote: Have you considered using an AUTOTEXTLIST field? See http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. Once the user chooses that person, it drops in the signautre block for that particular person from their autotext entry. Is this possible? And if so, can someone steer me in the right direction? |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
I take it that this is Word prior to 2007?
A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I thought about using the AUTOTEXTLIST but that won't work as the documents are different each time, and therefore won't have the prompt or trigger where they will right click to open the list. I don't want them to have to type in a word to right click on just to bring up that list where they want the signature. "Stefan Blom" wrote: Have you considered using an AUTOTEXTLIST field? See http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. Once the user chooses that person, it drops in the signautre block for that particular person from their autotext entry. Is this possible? And if so, can someone steer me in the right direction? |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
That would be fine if it were within a Form. This is just in general
documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: I take it that this is Word prior to 2007? A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I thought about using the AUTOTEXTLIST but that won't work as the documents are different each time, and therefore won't have the prompt or trigger where they will right click to open the list. I don't want them to have to type in a word to right click on just to bring up that list where they want the signature. "Stefan Blom" wrote: Have you considered using an AUTOTEXTLIST field? See http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. Once the user chooses that person, it drops in the signautre block for that particular person from their autotext entry. Is this possible? And if so, can someone steer me in the right direction? |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
Word 2007 has the building blocks organizer which you can add to the QAT and
pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: I take it that this is Word prior to 2007? A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I thought about using the AUTOTEXTLIST but that won't work as the documents are different each time, and therefore won't have the prompt or trigger where they will right click to open the list. I don't want them to have to type in a word to right click on just to bring up that list where they want the signature. "Stefan Blom" wrote: Have you considered using an AUTOTEXTLIST field? See http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. Once the user chooses that person, it drops in the signautre block for that particular person from their autotext entry. Is this possible? And if so, can someone steer me in the right direction? |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
Now this line:
'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: I take it that this is Word prior to 2007? A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I thought about using the AUTOTEXTLIST but that won't work as the documents are different each time, and therefore won't have the prompt or trigger where they will right click to open the list. I don't want them to have to type in a word to right click on just to bring up that list where they want the signature. "Stefan Blom" wrote: Have you considered using an AUTOTEXTLIST field? See http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. Once the user chooses that person, it drops in the signautre block for that particular person from their autotext entry. Is this possible? And if so, can someone steer me in the right direction? |
#8
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
I guess you are using the case statement version to retain your autotext
names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: I take it that this is Word prior to 2007? A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I thought about using the AUTOTEXTLIST but that won't work as the documents are different each time, and therefore won't have the prompt or trigger where they will right click to open the list. I don't want them to have to type in a word to right click on just to bring up that list where they want the signature. "Stefan Blom" wrote: Have you considered using an AUTOTEXTLIST field? See http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. Once the user chooses that person, it drops in the signautre block for that particular person from their autotext entry. Is this possible? And if so, can someone steer me in the right direction? |
#9
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
I'm not sure what a case statement name is. The first autotext entry I have
is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: I take it that this is Word prior to 2007? A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I thought about using the AUTOTEXTLIST but that won't work as the documents are different each time, and therefore won't have the prompt or trigger where they will right click to open the list. I don't want them to have to type in a word to right click on just to bring up that list where they want the signature. "Stefan Blom" wrote: Have you considered using an AUTOTEXTLIST field? See http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. Once the user chooses that person, it drops in the signautre block for that particular person from their autotext entry. Is this possible? And if so, can someone steer me in the right direction? |
#10
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
In that case, leave the entries in normal.dot and use the following, which,
if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: I take it that this is Word prior to 2007? A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I thought about using the AUTOTEXTLIST but that won't work as the documents are different each time, and therefore won't have the prompt or trigger where they will right click to open the list. I don't want them to have to type in a word to right click on just to bring up that list where they want the signature. "Stefan Blom" wrote: Have you considered using an AUTOTEXTLIST field? See http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. Once the user chooses that person, it drops in the signautre block for that particular person from their autotext entry. Is this possible? And if so, can someone steer me in the right direction? |
#11
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
Graham,
If I am ever in your neck of the woods, I definately owe you a beer! This worked! I really appreciate your help with all of this. I never would have been able to figure that out. Brian "Graham Mayor" wrote: In that case, leave the entries in normal.dot and use the following, which, if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: I take it that this is Word prior to 2007? A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I thought about using the AUTOTEXTLIST but that won't work as the documents are different each time, and therefore won't have the prompt or trigger where they will right click to open the list. I don't want them to have to type in a word to right click on just to bring up that list where they want the signature. "Stefan Blom" wrote: Have you considered using an AUTOTEXTLIST field? See http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. Once the user chooses that person, it drops in the signautre block for that particular person from their autotext entry. Is this possible? And if so, can someone steer me in the right direction? |
#12
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
You are welcome
-- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Graham, If I am ever in your neck of the woods, I definately owe you a beer! This worked! I really appreciate your help with all of this. I never would have been able to figure that out. Brian "Graham Mayor" wrote: In that case, leave the entries in normal.dot and use the following, which, if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: I take it that this is Word prior to 2007? A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I thought about using the AUTOTEXTLIST but that won't work as the documents are different each time, and therefore won't have the prompt or trigger where they will right click to open the list. I don't want them to have to type in a word to right click on just to bring up that list where they want the signature. "Stefan Blom" wrote: Have you considered using an AUTOTEXTLIST field? See http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. Once the user chooses that person, it drops in the signautre block for that particular person from their autotext entry. Is this possible? And if so, can someone steer me in the right direction? |
#13
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
Howdy Graham, you were so much help with my other question, I have a new one
for you. This is something that is possible within WordPerfect 10, but am not sure if its possible in Word 2007. I have a template, and a user has to enter names of people, but for any given time, there may be 5 names, or there may be 2 names. In WP, I can have it continuously ask for a name, until you leave the field blank and hit enter, then it continues onto the next entry (like date or whatever). Is there a way to have Word 07 ask the same question (in this instance "Defendant's Name") until you leave the field blank? We don't know from case to case how many defendants there will be. Thanks in advance! "Graham Mayor" wrote: You are welcome -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Graham, If I am ever in your neck of the woods, I definately owe you a beer! This worked! I really appreciate your help with all of this. I never would have been able to figure that out. Brian "Graham Mayor" wrote: In that case, leave the entries in normal.dot and use the following, which, if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: I take it that this is Word prior to 2007? A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I thought about using the AUTOTEXTLIST but that won't work as the documents are different each time, and therefore won't have the prompt or trigger where they will right click to open the list. I don't want them to have to type in a word to right click on just to bring up that list where they want the signature. "Stefan Blom" wrote: Have you considered using an AUTOTEXTLIST field? See http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. |
#14
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
You could do it with vba and a userform to ask the question and paste the
result into the document and do this repeatedly until you tell it to stop. Userform coding does not lend itself readily to reproduction in a newsgroup forum, but see Word MVP FAQ - Userforms http://word.mvps.org/FAQs/Userforms.htm to get you started. You will find lots of interesting userform examples on fellow MVP Greg Maxey's web site http://gregmaxey.mvps.org/word_tips.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Howdy Graham, you were so much help with my other question, I have a new one for you. This is something that is possible within WordPerfect 10, but am not sure if its possible in Word 2007. I have a template, and a user has to enter names of people, but for any given time, there may be 5 names, or there may be 2 names. In WP, I can have it continuously ask for a name, until you leave the field blank and hit enter, then it continues onto the next entry (like date or whatever). Is there a way to have Word 07 ask the same question (in this instance "Defendant's Name") until you leave the field blank? We don't know from case to case how many defendants there will be. Thanks in advance! "Graham Mayor" wrote: You are welcome -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Graham, If I am ever in your neck of the woods, I definately owe you a beer! This worked! I really appreciate your help with all of this. I never would have been able to figure that out. Brian "Graham Mayor" wrote: In that case, leave the entries in normal.dot and use the following, which, if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: I take it that this is Word prior to 2007? A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I thought about using the AUTOTEXTLIST but that won't work as the documents are different each time, and therefore won't have the prompt or trigger where they will right click to open the list. I don't want them to have to type in a word to right click on just to bring up that list where they want the signature. "Stefan Blom" wrote: Have you considered using an AUTOTEXTLIST field? See http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm. -- Stefan Blom Microsoft Word MVP "Trefilov22" wrote in message ... Here's what I need to do. I need to create a macro that opens a list that the user can choose a specific person from. A little background, I have signature blocks for nine people set as autotext. I need to create a macro that brings up a list of those nine people, that a user can choose one from. |
#15
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
I took a look at both sites, but haven't had any luck finding anything in
regards to this. It seems like in theory it would be something that isn't too difficult to do, I just know nothing about VBA to figure out how to program it to do so. Basically what you are saying is that I would make a form that asks for a Name or whatever I am looking for, and so long as there is an entry, it drops that name into the document, and then asks for another name. If it ends up being blank, at that point it stops the process (at least thats how its done in WP 10). I can see where you all have to work your tails off to learn all of this stuff to become MVPs. Luckily once I get this last problem sorted out I can wash my hands of these macros. All the others are working correctly. I just have this issue in multiple forms. Any other suggestions on where I can search? Brian "Graham Mayor" wrote: You could do it with vba and a userform to ask the question and paste the result into the document and do this repeatedly until you tell it to stop. Userform coding does not lend itself readily to reproduction in a newsgroup forum, but see Word MVP FAQ - Userforms http://word.mvps.org/FAQs/Userforms.htm to get you started. You will find lots of interesting userform examples on fellow MVP Greg Maxey's web site http://gregmaxey.mvps.org/word_tips.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Howdy Graham, you were so much help with my other question, I have a new one for you. This is something that is possible within WordPerfect 10, but am not sure if its possible in Word 2007. I have a template, and a user has to enter names of people, but for any given time, there may be 5 names, or there may be 2 names. In WP, I can have it continuously ask for a name, until you leave the field blank and hit enter, then it continues onto the next entry (like date or whatever). Is there a way to have Word 07 ask the same question (in this instance "Defendant's Name") until you leave the field blank? We don't know from case to case how many defendants there will be. Thanks in advance! "Graham Mayor" wrote: You are welcome -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Graham, If I am ever in your neck of the woods, I definately owe you a beer! This worked! I really appreciate your help with all of this. I never would have been able to figure that out. Brian "Graham Mayor" wrote: In that case, leave the entries in normal.dot and use the following, which, if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: I take it that this is Word prior to 2007? A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- |
#16
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
While I would prefer a user form, you can still do this with an input box.
The following will do more or less what you asked - in that it will allow the user to enter a series of names which are entered at the cursor. The list of names is stored in a variable sDef, which you could use elsewhere, but for the moment the variable is not used. Sub Defendant() Dim sName As String Dim sDef As String Dim Count As Long Count = 1 sDef = "" Do sName = InputBox("Enter the name of Defendant " & _ Count, "Defendant " & Count) If sName = "" Then GoTo NoMoreNames: If Count 1 Then sName = Chr(44) & Chr(32) & sName End If Selection.TypeText sName Count = Count + 1 sDef = sDef & sName Loop Exit Sub NoMoreNames: 'MsgBox sDef If Count 1 Then Selection.TypeText " " End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I took a look at both sites, but haven't had any luck finding anything in regards to this. It seems like in theory it would be something that isn't too difficult to do, I just know nothing about VBA to figure out how to program it to do so. Basically what you are saying is that I would make a form that asks for a Name or whatever I am looking for, and so long as there is an entry, it drops that name into the document, and then asks for another name. If it ends up being blank, at that point it stops the process (at least thats how its done in WP 10). I can see where you all have to work your tails off to learn all of this stuff to become MVPs. Luckily once I get this last problem sorted out I can wash my hands of these macros. All the others are working correctly. I just have this issue in multiple forms. Any other suggestions on where I can search? Brian "Graham Mayor" wrote: You could do it with vba and a userform to ask the question and paste the result into the document and do this repeatedly until you tell it to stop. Userform coding does not lend itself readily to reproduction in a newsgroup forum, but see Word MVP FAQ - Userforms http://word.mvps.org/FAQs/Userforms.htm to get you started. You will find lots of interesting userform examples on fellow MVP Greg Maxey's web site http://gregmaxey.mvps.org/word_tips.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Howdy Graham, you were so much help with my other question, I have a new one for you. This is something that is possible within WordPerfect 10, but am not sure if its possible in Word 2007. I have a template, and a user has to enter names of people, but for any given time, there may be 5 names, or there may be 2 names. In WP, I can have it continuously ask for a name, until you leave the field blank and hit enter, then it continues onto the next entry (like date or whatever). Is there a way to have Word 07 ask the same question (in this instance "Defendant's Name") until you leave the field blank? We don't know from case to case how many defendants there will be. Thanks in advance! "Graham Mayor" wrote: You are welcome -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Graham, If I am ever in your neck of the woods, I definately owe you a beer! This worked! I really appreciate your help with all of this. I never would have been able to figure that out. Brian "Graham Mayor" wrote: In that case, leave the entries in normal.dot and use the following, which, if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: I take it that this is Word prior to 2007? A userform would bemore elegant, but you can create a simple macro that would allow you to enter a single number to insert the appropriate autotext. eg Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("John's Sig").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Fred's Sig").Insert _ Whe=Selection.Range, RichText:=True 'etc End Select End Sub Add the rest of the Case statements and change the names and autotext names as appropriate. You can make this much simpler and do away with the Case statements if you re-name the autotexts to match the numbers eg Sig1 for John, Sig2 for Fred etc. Then Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9", , 1) NormalTemplate.AutoTextEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True End Sub It wouldn't be too much of a stretch to enable each user to have his own signature as default, but this should keep you going for a bit http://www.gmayor.com/installing_macro.htm -- |
#17
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
I would prefer to use a userform as well, since the rest of the information
is inputted using a userform. Is it possible to have this run after the user fills in the rest of the userform? Also how would I distinguish where the information it asks, goes into the document? Would I just create a bookmark and assign it that way? "Graham Mayor" wrote: While I would prefer a user form, you can still do this with an input box. The following will do more or less what you asked - in that it will allow the user to enter a series of names which are entered at the cursor. The list of names is stored in a variable sDef, which you could use elsewhere, but for the moment the variable is not used. Sub Defendant() Dim sName As String Dim sDef As String Dim Count As Long Count = 1 sDef = "" Do sName = InputBox("Enter the name of Defendant " & _ Count, "Defendant " & Count) If sName = "" Then GoTo NoMoreNames: If Count 1 Then sName = Chr(44) & Chr(32) & sName End If Selection.TypeText sName Count = Count + 1 sDef = sDef & sName Loop Exit Sub NoMoreNames: 'MsgBox sDef If Count 1 Then Selection.TypeText " " End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I took a look at both sites, but haven't had any luck finding anything in regards to this. It seems like in theory it would be something that isn't too difficult to do, I just know nothing about VBA to figure out how to program it to do so. Basically what you are saying is that I would make a form that asks for a Name or whatever I am looking for, and so long as there is an entry, it drops that name into the document, and then asks for another name. If it ends up being blank, at that point it stops the process (at least thats how its done in WP 10). I can see where you all have to work your tails off to learn all of this stuff to become MVPs. Luckily once I get this last problem sorted out I can wash my hands of these macros. All the others are working correctly. I just have this issue in multiple forms. Any other suggestions on where I can search? Brian "Graham Mayor" wrote: You could do it with vba and a userform to ask the question and paste the result into the document and do this repeatedly until you tell it to stop. Userform coding does not lend itself readily to reproduction in a newsgroup forum, but see Word MVP FAQ - Userforms http://word.mvps.org/FAQs/Userforms.htm to get you started. You will find lots of interesting userform examples on fellow MVP Greg Maxey's web site http://gregmaxey.mvps.org/word_tips.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Howdy Graham, you were so much help with my other question, I have a new one for you. This is something that is possible within WordPerfect 10, but am not sure if its possible in Word 2007. I have a template, and a user has to enter names of people, but for any given time, there may be 5 names, or there may be 2 names. In WP, I can have it continuously ask for a name, until you leave the field blank and hit enter, then it continues onto the next entry (like date or whatever). Is there a way to have Word 07 ask the same question (in this instance "Defendant's Name") until you leave the field blank? We don't know from case to case how many defendants there will be. Thanks in advance! "Graham Mayor" wrote: You are welcome -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Graham, If I am ever in your neck of the woods, I definately owe you a beer! This worked! I really appreciate your help with all of this. I never would have been able to figure that out. Brian "Graham Mayor" wrote: In that case, leave the entries in normal.dot and use the following, which, if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: |
#18
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
I suspect that userforms and their modification will be too complex for you
at the moment -and because of the way they are coded it is too difficult to describe how to modify them in a newsgroup forum. The code in the previous message simply enters the defendant names at the cursor. It could be modified to write them anywhere in the document or to store them in a bookmark. I think you are going to have to bite the bullet and dig into the mysteries of vba coding The learning curve is steep, but the vba forums will be very helpful in resolving individual problems. Either that or you will have to get someone to do the work for you. Try fellow MVP Greg Maxey whose site I referred you to earlier. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I would prefer to use a userform as well, since the rest of the information is inputted using a userform. Is it possible to have this run after the user fills in the rest of the userform? Also how would I distinguish where the information it asks, goes into the document? Would I just create a bookmark and assign it that way? "Graham Mayor" wrote: While I would prefer a user form, you can still do this with an input box. The following will do more or less what you asked - in that it will allow the user to enter a series of names which are entered at the cursor. The list of names is stored in a variable sDef, which you could use elsewhere, but for the moment the variable is not used. Sub Defendant() Dim sName As String Dim sDef As String Dim Count As Long Count = 1 sDef = "" Do sName = InputBox("Enter the name of Defendant " & _ Count, "Defendant " & Count) If sName = "" Then GoTo NoMoreNames: If Count 1 Then sName = Chr(44) & Chr(32) & sName End If Selection.TypeText sName Count = Count + 1 sDef = sDef & sName Loop Exit Sub NoMoreNames: 'MsgBox sDef If Count 1 Then Selection.TypeText " " End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I took a look at both sites, but haven't had any luck finding anything in regards to this. It seems like in theory it would be something that isn't too difficult to do, I just know nothing about VBA to figure out how to program it to do so. Basically what you are saying is that I would make a form that asks for a Name or whatever I am looking for, and so long as there is an entry, it drops that name into the document, and then asks for another name. If it ends up being blank, at that point it stops the process (at least thats how its done in WP 10). I can see where you all have to work your tails off to learn all of this stuff to become MVPs. Luckily once I get this last problem sorted out I can wash my hands of these macros. All the others are working correctly. I just have this issue in multiple forms. Any other suggestions on where I can search? Brian "Graham Mayor" wrote: You could do it with vba and a userform to ask the question and paste the result into the document and do this repeatedly until you tell it to stop. Userform coding does not lend itself readily to reproduction in a newsgroup forum, but see Word MVP FAQ - Userforms http://word.mvps.org/FAQs/Userforms.htm to get you started. You will find lots of interesting userform examples on fellow MVP Greg Maxey's web site http://gregmaxey.mvps.org/word_tips.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Howdy Graham, you were so much help with my other question, I have a new one for you. This is something that is possible within WordPerfect 10, but am not sure if its possible in Word 2007. I have a template, and a user has to enter names of people, but for any given time, there may be 5 names, or there may be 2 names. In WP, I can have it continuously ask for a name, until you leave the field blank and hit enter, then it continues onto the next entry (like date or whatever). Is there a way to have Word 07 ask the same question (in this instance "Defendant's Name") until you leave the field blank? We don't know from case to case how many defendants there will be. Thanks in advance! "Graham Mayor" wrote: You are welcome -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Graham, If I am ever in your neck of the woods, I definately owe you a beer! This worked! I really appreciate your help with all of this. I never would have been able to figure that out. Brian "Graham Mayor" wrote: In that case, leave the entries in normal.dot and use the following, which, if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser As Integer Dim sType As String iUser = InputBox("For John, enter 1" & vbCr & _ "For Fred, enter 2" & vbCr & _ "For Bill, enter 3" & vbCr & _ "For Susan, enter 4" & vbCr & _ "For Joan, enter 5" & vbCr & _ "For Alan, enter 6" & vbCr & _ "For Keith, enter 7" & vbCr & _ "For Elsie, enter 8" & vbCr & _ "For John, enter 9","Insert Signatures", 1) 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change End Sub See http://www.gmayor.com/installing_macro.htm and the signature autotexts need to be saved as autotexts in the normal template. If you are unsure how to do that it is illustrated at http://www.gmayor.com/Macrobutton.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Trefilov22 wrote: That would be fine if it were within a Form. This is just in general documents. Basically they'll type up something and then run this macro and then choose who they are (it would be easier if I could just assign their own signature macro to them on their own PC, but occassionally they type up something for someone else and would need to use their signature). In WordPerfect 10 they use a keystroke (ctrl-shft-M) and it brings up a box with all of their names listed, then they just click the name they want, and bam, in goes the signature. I would like to do something similiar, if not the same in Word 2007. Thanks Graham for your response, I appreciate it! Brian "Graham Mayor" wrote: |
#19
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
Brian,
If you are already using a userform to collect data for your form then I recommend that you use a multipage form and collect the defendent data on a separate page. The problem I have with a box that keeps popping up is a) they are annoying, and b) the user can't see what he or she has already entered until the form publishes. You could easily have 10 or 12 (or a hundred for that matter) text boxes on a separate page titled "Defendent's" list. The code in the userform would only process the fields filled in. Contact me if you are interested. Greg Maxey On Sep 10, 10:54 am, Trefilov22 wrote: I would prefer to use a userform as well, since the rest of the information is inputted using a userform. Is it possible to have this run after the user fills in the rest of the userform? Also how would I distinguish where the information it asks, goes into the document? Would I just create a bookmark and assign it that way? "Graham Mayor" wrote: While I would prefer a user form, you can still do this with an input box. The following will do more or less what you asked - in that it will allow the user to enter a series of names which are entered at the cursor. The list of names is stored in a variable sDef, which you could use elsewhere, but for the moment the variable is not used. Sub Defendant() Dim sName As String Dim sDef As String Dim Count As Long Count = 1 sDef = "" Do sName = InputBox("Enter the name of Defendant " & _ Count, "Defendant " & Count) If sName = "" Then GoTo NoMoreNames: If Count 1 Then sName = Chr(44) & Chr(32) & sName End If Selection.TypeText sName Count = Count + 1 sDef = sDef & sName Loop Exit Sub NoMoreNames: 'MsgBox sDef If Count 1 Then Selection.TypeText " " End Sub -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: I took a look at both sites, but haven't had any luck finding anything in regards to this. It seems like in theory it would be something that isn't too difficult to do, I just know nothing about VBA to figure out how to program it to do so. Basically what you are saying is that I would make a form that asks for a Name or whatever I am looking for, and so long as there is an entry, it drops that name into the document, and then asks for another name. If it ends up being blank, at that point it stops the process (at least thats how its done in WP 10). I can see where you all have to work your tails off to learn all of this stuff to become MVPs. Luckily once I get this last problem sorted out I can wash my hands of these macros. All the others are working correctly. I just have this issue in multiple forms. Any other suggestions on where I can search? Brian "Graham Mayor" wrote: You could do it with vba and a userform to ask the question and paste the result into the document and do this repeatedly until you tell it to stop. Userform coding does not lend itself readily to reproduction in a newsgroup forum, but see Word MVP FAQ - Userforms http://word.mvps.org/FAQs/Userforms.htmto get you started. You will find lots of interesting userform examples on fellow MVP Greg Maxey's web sitehttp://gregmaxey.mvps.org/word_tips.htm -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: Howdy Graham, you were so much help with my other question, I have a new one for you. This is something that is possible within WordPerfect 10, but am not sure if its possible in Word 2007. I have a template, and a user has to enter names of people, but for any given time, there may be 5 names, or there may be 2 names. In WP, I can have it continuously ask for a name, until you leave the field blank and hit enter, then it continues onto the next entry (like date or whatever). Is there a way to have Word 07 ask the same question (in this instance "Defendant's Name") until you leave the field blank? We don't know from case to case how many defendants there will be. Thanks in advance! "Graham Mayor" wrote: You are welcome -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: Graham, If I am ever in your neck of the woods, I definately owe you a beer! This worked! I really appreciate your help with all of this. I never would have been able to figure that out. Brian "Graham Mayor" wrote: In that case, leave the entries in normal.dot and use the following, which, if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser ... read more »- Hide quoted text - - Show quoted text - |
#20
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
Greg,
I am definately interested. That does sound the way to go. Bookmark form would work I am guessing. Basically it just needs to go in, sort of in a list type format. Like the first line would be John Doe, 2nd line would be Jane Doe 3rd line etc. etc. Where should I begin? Thanks in advance! Brian "Greg Maxey" wrote: Brian, If you are already using a userform to collect data for your form then I recommend that you use a multipage form and collect the defendent data on a separate page. The problem I have with a box that keeps popping up is a) they are annoying, and b) the user can't see what he or she has already entered until the form publishes. You could easily have 10 or 12 (or a hundred for that matter) text boxes on a separate page titled "Defendent's" list. The code in the userform would only process the fields filled in. Contact me if you are interested. Greg Maxey On Sep 10, 10:54 am, Trefilov22 wrote: I would prefer to use a userform as well, since the rest of the information is inputted using a userform. Is it possible to have this run after the user fills in the rest of the userform? Also how would I distinguish where the information it asks, goes into the document? Would I just create a bookmark and assign it that way? "Graham Mayor" wrote: While I would prefer a user form, you can still do this with an input box. The following will do more or less what you asked - in that it will allow the user to enter a series of names which are entered at the cursor. The list of names is stored in a variable sDef, which you could use elsewhere, but for the moment the variable is not used. Sub Defendant() Dim sName As String Dim sDef As String Dim Count As Long Count = 1 sDef = "" Do sName = InputBox("Enter the name of Defendant " & _ Count, "Defendant " & Count) If sName = "" Then GoTo NoMoreNames: If Count 1 Then sName = Chr(44) & Chr(32) & sName End If Selection.TypeText sName Count = Count + 1 sDef = sDef & sName Loop Exit Sub NoMoreNames: 'MsgBox sDef If Count 1 Then Selection.TypeText " " End Sub -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: I took a look at both sites, but haven't had any luck finding anything in regards to this. It seems like in theory it would be something that isn't too difficult to do, I just know nothing about VBA to figure out how to program it to do so. Basically what you are saying is that I would make a form that asks for a Name or whatever I am looking for, and so long as there is an entry, it drops that name into the document, and then asks for another name. If it ends up being blank, at that point it stops the process (at least thats how its done in WP 10). I can see where you all have to work your tails off to learn all of this stuff to become MVPs. Luckily once I get this last problem sorted out I can wash my hands of these macros. All the others are working correctly. I just have this issue in multiple forms. Any other suggestions on where I can search? Brian "Graham Mayor" wrote: You could do it with vba and a userform to ask the question and paste the result into the document and do this repeatedly until you tell it to stop. Userform coding does not lend itself readily to reproduction in a newsgroup forum, but see Word MVP FAQ - Userforms http://word.mvps.org/FAQs/Userforms.htmto get you started. You will find lots of interesting userform examples on fellow MVP Greg Maxey's web sitehttp://gregmaxey.mvps.org/word_tips.htm -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: Howdy Graham, you were so much help with my other question, I have a new one for you. This is something that is possible within WordPerfect 10, but am not sure if its possible in Word 2007. I have a template, and a user has to enter names of people, but for any given time, there may be 5 names, or there may be 2 names. In WP, I can have it continuously ask for a name, until you leave the field blank and hit enter, then it continues onto the next entry (like date or whatever). Is there a way to have Word 07 ask the same question (in this instance "Defendant's Name") until you leave the field blank? We don't know from case to case how many defendants there will be. Thanks in advance! "Graham Mayor" wrote: You are welcome -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: Graham, If I am ever in your neck of the woods, I definately owe you a beer! This worked! I really appreciate your help with all of this. I never would have been able to figure that out. Brian "Graham Mayor" wrote: In that case, leave the entries in normal.dot and use the following, which, if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser ... read more ;- Hide quoted text - - Show quoted text - |
#21
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
Contact me via the user feedback link on my website
http://gregmaxey.mvps.org/word_tips.htm -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. "Trefilov22" wrote in message ... Greg, I am definately interested. That does sound the way to go. Bookmark form would work I am guessing. Basically it just needs to go in, sort of in a list type format. Like the first line would be John Doe, 2nd line would be Jane Doe 3rd line etc. etc. Where should I begin? Thanks in advance! Brian "Greg Maxey" wrote: Brian, If you are already using a userform to collect data for your form then I recommend that you use a multipage form and collect the defendent data on a separate page. The problem I have with a box that keeps popping up is a) they are annoying, and b) the user can't see what he or she has already entered until the form publishes. You could easily have 10 or 12 (or a hundred for that matter) text boxes on a separate page titled "Defendent's" list. The code in the userform would only process the fields filled in. Contact me if you are interested. Greg Maxey On Sep 10, 10:54 am, Trefilov22 wrote: I would prefer to use a userform as well, since the rest of the information is inputted using a userform. Is it possible to have this run after the user fills in the rest of the userform? Also how would I distinguish where the information it asks, goes into the document? Would I just create a bookmark and assign it that way? "Graham Mayor" wrote: While I would prefer a user form, you can still do this with an input box. The following will do more or less what you asked - in that it will allow the user to enter a series of names which are entered at the cursor. The list of names is stored in a variable sDef, which you could use elsewhere, but for the moment the variable is not used. Sub Defendant() Dim sName As String Dim sDef As String Dim Count As Long Count = 1 sDef = "" Do sName = InputBox("Enter the name of Defendant " & _ Count, "Defendant " & Count) If sName = "" Then GoTo NoMoreNames: If Count 1 Then sName = Chr(44) & Chr(32) & sName End If Selection.TypeText sName Count = Count + 1 sDef = sDef & sName Loop Exit Sub NoMoreNames: 'MsgBox sDef If Count 1 Then Selection.TypeText " " End Sub -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: I took a look at both sites, but haven't had any luck finding anything in regards to this. It seems like in theory it would be something that isn't too difficult to do, I just know nothing about VBA to figure out how to program it to do so. Basically what you are saying is that I would make a form that asks for a Name or whatever I am looking for, and so long as there is an entry, it drops that name into the document, and then asks for another name. If it ends up being blank, at that point it stops the process (at least thats how its done in WP 10). I can see where you all have to work your tails off to learn all of this stuff to become MVPs. Luckily once I get this last problem sorted out I can wash my hands of these macros. All the others are working correctly. I just have this issue in multiple forms. Any other suggestions on where I can search? Brian "Graham Mayor" wrote: You could do it with vba and a userform to ask the question and paste the result into the document and do this repeatedly until you tell it to stop. Userform coding does not lend itself readily to reproduction in a newsgroup forum, but see Word MVP FAQ - Userforms http://word.mvps.org/FAQs/Userforms.htmto get you started. You will find lots of interesting userform examples on fellow MVP Greg Maxey's web sitehttp://gregmaxey.mvps.org/word_tips.htm -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: Howdy Graham, you were so much help with my other question, I have a new one for you. This is something that is possible within WordPerfect 10, but am not sure if its possible in Word 2007. I have a template, and a user has to enter names of people, but for any given time, there may be 5 names, or there may be 2 names. In WP, I can have it continuously ask for a name, until you leave the field blank and hit enter, then it continues onto the next entry (like date or whatever). Is there a way to have Word 07 ask the same question (in this instance "Defendant's Name") until you leave the field blank? We don't know from case to case how many defendants there will be. Thanks in advance! "Graham Mayor" wrote: You are welcome -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: Graham, If I am ever in your neck of the woods, I definately owe you a beer! This worked! I really appreciate your help with all of this. I never would have been able to figure that out. Brian "Graham Mayor" wrote: In that case, leave the entries in normal.dot and use the following, which, if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: Now this line: 'change the following line NormalTemplate.BuildingBlockEntries("Sig" & iUser).Insert _ Whe=Selection.Range, RichText:=True 'end of change is entered multiple times, changing the "Sig" to read whatever the name of the autotext entry is? Then I put in the second, and third, etc. "Graham Mayor" wrote: Word 2007 has the building blocks organizer which you can add to the QAT and pick the autotexts (the signature blocks) from a list. The macro I posted will simply insert the right signature blocks *in any document* - provided they are named correctly. However it will not work as it stands in Word 2007 as autotext entries work in a slightly different way there to earlier versions. If we take the second example - it needs the following change. Sub ChooseSig() Dim iUser ... read more ;- Hide quoted text - - Show quoted text - |
#22
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
A Macro that calls another Macro
Done!
Brian "Greg Maxey" wrote: Contact me via the user feedback link on my website http://gregmaxey.mvps.org/word_tips.htm -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. "Trefilov22" wrote in message ... Greg, I am definately interested. That does sound the way to go. Bookmark form would work I am guessing. Basically it just needs to go in, sort of in a list type format. Like the first line would be John Doe, 2nd line would be Jane Doe 3rd line etc. etc. Where should I begin? Thanks in advance! Brian "Greg Maxey" wrote: Brian, If you are already using a userform to collect data for your form then I recommend that you use a multipage form and collect the defendent data on a separate page. The problem I have with a box that keeps popping up is a) they are annoying, and b) the user can't see what he or she has already entered until the form publishes. You could easily have 10 or 12 (or a hundred for that matter) text boxes on a separate page titled "Defendent's" list. The code in the userform would only process the fields filled in. Contact me if you are interested. Greg Maxey On Sep 10, 10:54 am, Trefilov22 wrote: I would prefer to use a userform as well, since the rest of the information is inputted using a userform. Is it possible to have this run after the user fills in the rest of the userform? Also how would I distinguish where the information it asks, goes into the document? Would I just create a bookmark and assign it that way? "Graham Mayor" wrote: While I would prefer a user form, you can still do this with an input box. The following will do more or less what you asked - in that it will allow the user to enter a series of names which are entered at the cursor. The list of names is stored in a variable sDef, which you could use elsewhere, but for the moment the variable is not used. Sub Defendant() Dim sName As String Dim sDef As String Dim Count As Long Count = 1 sDef = "" Do sName = InputBox("Enter the name of Defendant " & _ Count, "Defendant " & Count) If sName = "" Then GoTo NoMoreNames: If Count 1 Then sName = Chr(44) & Chr(32) & sName End If Selection.TypeText sName Count = Count + 1 sDef = sDef & sName Loop Exit Sub NoMoreNames: 'MsgBox sDef If Count 1 Then Selection.TypeText " " End Sub -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: I took a look at both sites, but haven't had any luck finding anything in regards to this. It seems like in theory it would be something that isn't too difficult to do, I just know nothing about VBA to figure out how to program it to do so. Basically what you are saying is that I would make a form that asks for a Name or whatever I am looking for, and so long as there is an entry, it drops that name into the document, and then asks for another name. If it ends up being blank, at that point it stops the process (at least thats how its done in WP 10). I can see where you all have to work your tails off to learn all of this stuff to become MVPs. Luckily once I get this last problem sorted out I can wash my hands of these macros. All the others are working correctly. I just have this issue in multiple forms. Any other suggestions on where I can search? Brian "Graham Mayor" wrote: You could do it with vba and a userform to ask the question and paste the result into the document and do this repeatedly until you tell it to stop. Userform coding does not lend itself readily to reproduction in a newsgroup forum, but see Word MVP FAQ - Userforms http://word.mvps.org/FAQs/Userforms.htmto get you started. You will find lots of interesting userform examples on fellow MVP Greg Maxey's web sitehttp://gregmaxey.mvps.org/word_tips.htm -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: Howdy Graham, you were so much help with my other question, I have a new one for you. This is something that is possible within WordPerfect 10, but am not sure if its possible in Word 2007. I have a template, and a user has to enter names of people, but for any given time, there may be 5 names, or there may be 2 names. In WP, I can have it continuously ask for a name, until you leave the field blank and hit enter, then it continues onto the next entry (like date or whatever). Is there a way to have Word 07 ask the same question (in this instance "Defendant's Name") until you leave the field blank? We don't know from case to case how many defendants there will be. Thanks in advance! "Graham Mayor" wrote: You are welcome -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: Graham, If I am ever in your neck of the woods, I definately owe you a beer! This worked! I really appreciate your help with all of this. I never would have been able to figure that out. Brian "Graham Mayor" wrote: In that case, leave the entries in normal.dot and use the following, which, if the entries are named as you describe and in normal.dot, should work as it stands. Sub ChooseSig() Dim iUser As Integer Dim sType As String On Error GoTo UserCancelled: iUser = InputBox("For Bethany, enter 1" & vbCr & _ "For Heather, enter 2" & vbCr & _ "For Jim, enter 3" & vbCr & _ "For Kathy Hutchens, enter 4" & vbCr & _ "For Kathy McCallister, enter 5" & vbCr & _ "For Kelli, enter 6" & vbCr & _ "For Krista, enter 7" & vbCr & _ "For Rhonda, enter 8" & vbCr & _ "For Thala, enter 9", "Select signature", 1) Select Case iUser Case 1 NormalTemplate.AutoTextEntries("Bethany").Insert _ Whe=Selection.Range, RichText:=True Case 2 NormalTemplate.AutoTextEntries("Heather").Insert _ Whe=Selection.Range, RichText:=True Case 3 NormalTemplate.AutoTextEntries("Jim").Insert _ Whe=Selection.Range, RichText:=True Case 4 NormalTemplate.AutoTextEntries("Kathy Hutchens").Insert _ Whe=Selection.Range, RichText:=True Case 5 NormalTemplate.AutoTextEntries("Kathy McCallister").Insert _ Whe=Selection.Range, RichText:=True Case 6 NormalTemplate.AutoTextEntries("Kelli").Insert _ Whe=Selection.Range, RichText:=True Case 7 NormalTemplate.AutoTextEntries("Krista").Insert _ Whe=Selection.Range, RichText:=True Case 8 NormalTemplate.AutoTextEntries("Rhonda").Insert _ Whe=Selection.Range, RichText:=True Case 9 NormalTemplate.AutoTextEntries("Thala").Insert _ Whe=Selection.Range, RichText:=True Case Else MsgBox "You have entered a number that is not in the list", _ vbInformation, "Error" End Select Exit Sub UserCancelled: MsgBox "User Cancelled", vbInformation, "Error" End Sub -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: I'm not sure what a case statement name is. The first autotext entry I have is named Bethany and its saved in the normal.dotm Should I move this to the building blocks.dotx? here are the names of the autotext entries: Bethany Heather Jim Kathy Hutchens Kathy McCallister Kelli Krista Rhonda Thala All are in the normal.dotm "Graham Mayor" wrote: I guess you are using the case statement version to retain your autotext names? Rather than the macro posted below? In this case put the names of your autotexts in quotes between the brackets in place of "Sig" & iUser Note that this will require you to ensure that your autotexts are actually saved in normal.dot (you can move them with the building block organiser) It makes for a lot less code if you simple recreate your signatures with the names Sig1, Sig2 etc (insert and resave) and use the shorter macro below. Then all you have to do is change the names in the message box to match the signature numbers. -- Graham Mayor - Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org Trefilov22 wrote: Now this line: |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro cannot be found or has been disabled because of Macro settin | Microsoft Word Help | |||
Pause an executing Word Macro to enter info and then Macro continu | Microsoft Word Help | |||
macro runs from keyboard, but not from macro button-why? | Microsoft Word Help | |||
Running Macro from Word vs running macro from vb.net prog | New Users | |||
2000 to 2002 macro and "Could not open macro storage" | Mailmerge |