Solved Word VBA Dependent Drop Down Error

September 26, 2017 at 03:08:21
Specs: Windows 7
I have been trying to create a dependent drop down box, where I enter a name in one drop down box and the relevant number is given in another.

I used the design mode to create 2 drop down form field boxes. One is populated with the names, ddName and the other is empty and called ddNumber.

I created a new module in VBA as follows:

<code><span>Sub PopulateddNumber()</span>
<code><span> Select Case ActiveDocument.FormFields("ddName").Result</span>
<code><span> Case "Izaskun"</span>
<code><span> With ActiveDocument.FormFields("ddNumber").DropDown.ListEntries</span>
<code><span> .Clear</span>
<code><span> .Add "398353"</span>
<code><span> End With</span>
<code><span> Case "Jules"</span>
<code><span> With ActiveDocument.FormFields("ddNumber").DropDown.ListEntries</span>
<code><span> .Clear</span>
<code><span> .Add "398361"</span>
<code><span> End With</span>
<code><span> End Select</span>
<code><span> End Sub</span>

However, I keep getting an error popping up: compile error expected: line or labeled statement or end of statement.

I'm a compete VBA n00b and so any help would be appreciated.

message edited by ShellyBeth


See More: Word VBA Dependent Drop Down Error

Reply ↓  Report •

#1
September 26, 2017 at 03:41:33
What are the all <code><span> tags for? Those are not valid for Excel Word VBA.

Are they actually part of your code or just something you used to try and post your code in this forum?

How To Post Data or Code ---> Click Here Before Posting Data or VBA Code

message edited by DerbyDad03


Reply ↓  Report •

#2
September 26, 2017 at 03:47:49
✔ Best Answer
This code was actually given to me by a colleague, so I presume they used these tags for something? So I can just delete these completely from my VBA?

Thanks!

EDIT: Just deleted those and it works! I knew it would be something ridiculously, stupidly simple that I was doing wrong. Thanks for your help!

message edited by ShellyBeth


Reply ↓  Report •

#3
September 26, 2017 at 05:26:28
I'm glad you worked it out. I'll mark the thread as solved.

How To Post Data or Code ---> Click Here Before Posting Data or VBA Code


Reply ↓  Report •
Related Solutions


Ask Question