|
|
|
date: Wed, 15 Oct 2008 06:26:01 -0700,
group: microsoft.public.word.vba.general
back
Re: VBA code required
The .DropDown.Value for a dropdown formfield returns a number that coincides
with the order of the item that is select from the list. Therefore, for a
DropDown formfield that contained say the items Tom, Dick and Harry, you
could use:
Dim emaddress As String
Select Case ActiveDocument.FormFields("DropDown1").DropDown.Value
Case 1
emaddress = "Tom@somedomain.com"
Case 2
emaddress = "Dick@somedomain.com"
Case 3
emaddress = "Harry@somedomain.com"
End Select
MsgBox emaddress
in a macro that ran on exit from the formfield. In your existing code, you
would then use
Recipients:= emaddress
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"Vinod Lewis" wrote in message
news:D24F500A-1432-4701-B45F-F5CF5EB4E642@microsoft.com...
> Thank you for your reply.
>
> I dont know to write a code, so i need the code with the instruction.
>
> The code which i have pasted is from one of the post.
>
> Any help is appreciated
>
> "Doug Robbins - Word MVP" wrote:
>
>> You could use a Select Case ... End Select construction that evaluated
>> the
>> ..Result of the Drop Down Formfield and returned the appropriate email
>> address.
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Vinod Lewis" wrote in message
>> news:60723CA2-4EF8-41B2-811D-A386D1D1F02D@microsoft.com...
>> >I am creating a Leave application word form, where i need my users to
>> >click
>> > the submit button and that sends an email out.
>> >
>> > Application word 2007
>> >
>> > This code works fine when the recepient clicks the submit button, the
>> > recepient of the email is the one specified in the code.
>> >
>> > ActiveDocument.SendForReview _
>> > Recipients:="Your Email address here", _
>> > Subject:="Your Subject here", _
>> > ShowMessage:=False, _
>> > IncludeAttachment:=True
>> > MsgBox "Your Message has been sent!"
>> >
>> > Help
>> > ====
>> > In my form i have a combo box where the user selects a department in
>> > which
>> > he is working, based on that department when the user clicks the submit
>> > button. one email should go to the head of the selected department and
>> > one
>> > email to the HR department. I need a code for that
>> >
>> > Any help is appreciated.
>>
>>
>>
date: Thu, 16 Oct 2008 20:38:12 +1000
author: Doug Robbins - Word MVP
Re: VBA code required
I really appreciate that you are trying to help me out. I am not able to do it.
Here is what i did,
I created a macro using your code. though i have a combo box in my form, i
changed to it to drop down
Dim emaddress As String
Select Case ActiveDocument.FormFields("DropDown1").DropDown.Value
Case 1
emaddress = "Tom@somedomain.com"
Case 2
emaddress = "Dick@somedomain.com"
End Select
MsgBox emaddress
This code runs if i assign to any form field exit.
Then you told me to change this in my submit code.
Recipients:= emaddress
I am doing something wrong, this macro and the submit button should combine
to get the results.
If you could write the complete code and tell where to place what, that
would be a great help.
waiting for an answer. Thanking you in advance.
"Doug Robbins - Word MVP" wrote:
> The .DropDown.Value for a dropdown formfield returns a number that coincides
> with the order of the item that is select from the list. Therefore, for a
> DropDown formfield that contained say the items Tom, Dick and Harry, you
> could use:
>
> Dim emaddress As String
> Select Case ActiveDocument.FormFields("DropDown1").DropDown.Value
> Case 1
> emaddress = "Tom@somedomain.com"
> Case 2
> emaddress = "Dick@somedomain.com"
> Case 3
> emaddress = "Harry@somedomain.com"
> End Select
> MsgBox emaddress
>
> in a macro that ran on exit from the formfield. In your existing code, you
> would then use
>
> Recipients:= emaddress
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Vinod Lewis" wrote in message
> news:D24F500A-1432-4701-B45F-F5CF5EB4E642@microsoft.com...
> > Thank you for your reply.
> >
> > I dont know to write a code, so i need the code with the instruction.
> >
> > The code which i have pasted is from one of the post.
> >
> > Any help is appreciated
> >
> > "Doug Robbins - Word MVP" wrote:
> >
> >> You could use a Select Case ... End Select construction that evaluated
> >> the
> >> ..Result of the Drop Down Formfield and returned the appropriate email
> >> address.
> >>
> >> --
> >> Hope this helps.
> >>
> >> Please reply to the newsgroup unless you wish to avail yourself of my
> >> services on a paid consulting basis.
> >>
> >> Doug Robbins - Word MVP
> >>
> >> "Vinod Lewis" wrote in message
> >> news:60723CA2-4EF8-41B2-811D-A386D1D1F02D@microsoft.com...
> >> >I am creating a Leave application word form, where i need my users to
> >> >click
> >> > the submit button and that sends an email out.
> >> >
> >> > Application word 2007
> >> >
> >> > This code works fine when the recepient clicks the submit button, the
> >> > recepient of the email is the one specified in the code.
> >> >
> >> > ActiveDocument.SendForReview _
> >> > Recipients:="Your Email address here", _
> >> > Subject:="Your Subject here", _
> >> > ShowMessage:=False, _
> >> > IncludeAttachment:=True
> >> > MsgBox "Your Message has been sent!"
> >> >
> >> > Help
> >> > ====
> >> > In my form i have a combo box where the user selects a department in
> >> > which
> >> > he is working, based on that department when the user clicks the submit
> >> > button. one email should go to the head of the selected department and
> >> > one
> >> > email to the HR department. I need a code for that
> >> >
> >> > Any help is appreciated.
> >>
> >>
> >>
>
>
>
date: Thu, 16 Oct 2008 05:46:01 -0700
author: Vinod Lewis
Re: VBA code required
Instead of using that code in a macro that run on exit from the combobox
(which is actually a DropDown type Formfield), incorporate it into the macro
that you now have.
The MsgBox line is not needed, it was only there to show you how the code
worked when run on exit from the Drop Down formField.
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"Vinod Lewis" wrote in message
news:863A0781-F62E-494A-9E8B-B57D5391C93C@microsoft.com...
>I really appreciate that you are trying to help me out. I am not able to do
>it.
>
> Here is what i did,
>
> I created a macro using your code. though i have a combo box in my form, i
> changed to it to drop down
>
> Dim emaddress As String
> Select Case ActiveDocument.FormFields("DropDown1").DropDown.Value
> Case 1
> emaddress = "Tom@somedomain.com"
> Case 2
> emaddress = "Dick@somedomain.com"
> End Select
> MsgBox emaddress
>
> This code runs if i assign to any form field exit.
>
> Then you told me to change this in my submit code.
>
> Recipients:= emaddress
>
> I am doing something wrong, this macro and the submit button should
> combine
> to get the results.
>
> If you could write the complete code and tell where to place what, that
> would be a great help.
>
> waiting for an answer. Thanking you in advance.
>
> "Doug Robbins - Word MVP" wrote:
>
>> The .DropDown.Value for a dropdown formfield returns a number that
>> coincides
>> with the order of the item that is select from the list. Therefore, for
>> a
>> DropDown formfield that contained say the items Tom, Dick and Harry, you
>> could use:
>>
>> Dim emaddress As String
>> Select Case ActiveDocument.FormFields("DropDown1").DropDown.Value
>> Case 1
>> emaddress = "Tom@somedomain.com"
>> Case 2
>> emaddress = "Dick@somedomain.com"
>> Case 3
>> emaddress = "Harry@somedomain.com"
>> End Select
>> MsgBox emaddress
>>
>> in a macro that ran on exit from the formfield. In your existing code,
>> you
>> would then use
>>
>> Recipients:= emaddress
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Vinod Lewis" wrote in message
>> news:D24F500A-1432-4701-B45F-F5CF5EB4E642@microsoft.com...
>> > Thank you for your reply.
>> >
>> > I dont know to write a code, so i need the code with the instruction.
>> >
>> > The code which i have pasted is from one of the post.
>> >
>> > Any help is appreciated
>> >
>> > "Doug Robbins - Word MVP" wrote:
>> >
>> >> You could use a Select Case ... End Select construction that evaluated
>> >> the
>> >> ..Result of the Drop Down Formfield and returned the appropriate email
>> >> address.
>> >>
>> >> --
>> >> Hope this helps.
>> >>
>> >> Please reply to the newsgroup unless you wish to avail yourself of my
>> >> services on a paid consulting basis.
>> >>
>> >> Doug Robbins - Word MVP
>> >>
>> >> "Vinod Lewis" wrote in message
>> >> news:60723CA2-4EF8-41B2-811D-A386D1D1F02D@microsoft.com...
>> >> >I am creating a Leave application word form, where i need my users to
>> >> >click
>> >> > the submit button and that sends an email out.
>> >> >
>> >> > Application word 2007
>> >> >
>> >> > This code works fine when the recepient clicks the submit button,
>> >> > the
>> >> > recepient of the email is the one specified in the code.
>> >> >
>> >> > ActiveDocument.SendForReview _
>> >> > Recipients:="Your Email address here", _
>> >> > Subject:="Your Subject here", _
>> >> > ShowMessage:=False, _
>> >> > IncludeAttachment:=True
>> >> > MsgBox "Your Message has been sent!"
>> >> >
>> >> > Help
>> >> > ====
>> >> > In my form i have a combo box where the user selects a department in
>> >> > which
>> >> > he is working, based on that department when the user clicks the
>> >> > submit
>> >> > button. one email should go to the head of the selected department
>> >> > and
>> >> > one
>> >> > email to the HR department. I need a code for that
>> >> >
>> >> > Any help is appreciated.
>> >>
>> >>
>> >>
>>
>>
>>
date: Fri, 17 Oct 2008 05:46:41 +1000
author: Doug Robbins - Word MVP
|
|