PDA

View Full Version : question about dropdowns



cubbycub
11-26-2009, 04:01 AM
Hello I was wondering if someone could help me. Im reasonably new to VBA with some playing about with Excel macros but this is my first attempt with Word.

Im Useing Word2007 on a PC

We have a holiday request form, on that form i have a table, within that table i have a dropdown that we use to selct empoyee names. this is then just printed off and handed to the HR dep.

We now have a change in policy whereby the employee needs to hand the request in to their respective line manager.

I would like to automate this with a simple email button that sends the form attached as an email to the right person.

Im right at the start of this project and ive fallen down at the first hurdle. Im getting an error "the requested member of the collection does not exist"

Private Sub CommandButton1_Click()
Select Case ActiveDocument.FormFields("Dropdown1").DropDown.Value
Case "WhoEver"
Stop
Case Else
End Select
End Sub

Im suspecting that i cant have the dropdown in a table is this right?
or
Is "Dropdown1" a specific reference name that i have to change.

In short I dont know how to reference inputs to the form basically. Any help or pointing me in the right direction would be very appreciated.

Tinbendr
11-26-2009, 06:56 AM
An attached sample saved in W2003 format would be a nice start.


Im suspecting that i cant have the dropdown in a table is this right? No. Not a problem.


Is "Dropdown1" a specific reference name that i have to change.It doesn't have to be changed, but it has to match in the code.

cubbycub
11-26-2009, 08:20 AM
Thankyou for replying so quickly.

I have just tried to save the document as a 2003 word document and it lost the Controls. So i re-edited the doc using the legacy controls.

Now this does not throw up the error that i had with the 2007 controls.

Does this mean that i should just avoid using the 2007 controls and stick to the legacy ones?:dunno

attached are the files as requested

a 2003 version i'll also post the 2007 version as well

cubbycub
11-26-2009, 08:22 AM
This is the orig 2007 version

Tinbendr
11-27-2009, 12:58 AM
I'm not sure why you're getting the error, but change Dropdown1 to 2 (if you're testing for name) and change .DropDown.Value to Result.

Dropdown formfields have a limit of 25 entries. If you need more than this, use a Combobox.

But I'm not exactly sure what "a simple email button that sends the form attached as an email to the right person." means. Is the form to be emailed to the employee, or is the form to be emailed to the supervisor? I can't help but think that if you're going to distribute this to employees, then a form created in Outlook would be more suitable. Create a form, then place it on the network for everyone to use. The employee would be responsible for emailing it to the right person.