From: johnnykunst on 23 Apr 2010 03:08 Sub FillStateDD() Dim myArray1() As String Dim myArray2() As String Dim myArray3() As String Dim i As Long myArray1 = Split("AGU BCN BCS CAM CHP CHH") myArray2 = Split("CHH COA COL DIF DUR") myArray3 = Split("AL AK AS AZ AR CA CO CT DE DC FM FL GA GU") _ ActiveDocument.FormFields("StateDD").DropDown.ListEntries.Clear Select Case ActiveDocument.FormFields("CountryName").Result Case "Burgess Park Areas (a-m)" For i = 0 To UBound(myArray1) ActiveDocument.FormFields("StateDD").DropDown.ListEntries.Add myArray1(i) Next i Case "Mexico" For i = 0 To UBound(myArray2) ActiveDocument.FormFields("StateDD").DropDown.ListEntries.Add myArray2(i) Next i Case "USA" For i = 0 To UBound(myArray3) I'm using the following as a basis to populate a drop down in Word 2003 based on the previous entry in a drop down: ActiveDocument.FormFields("StateDD").DropDown.ListEntries.Add myArray3(i) Next i End Select End Sub The problem, is that rather than entering different words such as AGU or BCN, I want to use sentences; ie Burgess Park Area" and "Camberwell Green" but of course the space in between the two words makes each word sparate; how would I change the deliminter so that it's not the space, or should I be using something different to split? --- frmsrcurl: http://msgroups.net/microsoft.public.word.vba.general/
From: Doug Robbins - Word MVP on 23 Apr 2010 03:23 You can use anything as the separator, as long as you define it. For example: MyArray1 = Split("Burgess Park Area,Camberwell Green,etc", ",") MyArray1 = Split("Burgess Park Area|Camberwell Green|etc", "|") -- 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, originally posted via msnews.microsoft.com "johnnykunst" <user(a)msgroups.net/> wrote in message news:OINDIPr4KHA.5476(a)TK2MSFTNGP06.phx.gbl... > Sub FillStateDD() > Dim myArray1() As String > Dim myArray2() As String > Dim myArray3() As String > Dim i As Long > myArray1 = Split("AGU BCN BCS CAM CHP CHH") > myArray2 = Split("CHH COA COL DIF DUR") > myArray3 = Split("AL AK AS AZ AR CA CO CT DE DC FM FL GA GU") _ > > ActiveDocument.FormFields("StateDD").DropDown.ListEntries.Clear > Select Case ActiveDocument.FormFields("CountryName").Result > Case "Burgess Park Areas (a-m)" > For i = 0 To UBound(myArray1) > ActiveDocument.FormFields("StateDD").DropDown.ListEntries.Add > myArray1(i) > Next i > Case "Mexico" > For i = 0 To UBound(myArray2) > ActiveDocument.FormFields("StateDD").DropDown.ListEntries.Add > myArray2(i) > Next i > Case "USA" > For i = 0 To UBound(myArray3) > I'm using the following as a basis to populate a drop down in Word 2003 > based on the previous entry in a drop down: > ActiveDocument.FormFields("StateDD").DropDown.ListEntries.Add myArray3(i) > Next i > End Select > End Sub > > The problem, is that rather than entering different words such as AGU or > BCN, I want to use sentences; ie Burgess Park Area" and "Camberwell Green" > but of course the space in between the two words makes each word sparate; > how would I change the deliminter so that it's not the space, or should I > be using something different to split? > > --- > frmsrcurl: http://msgroups.net/microsoft.public.word.vba.general/
From: johnnykunst on 23 Apr 2010 13:11 That's brilliant, thank you. --- frmsrcurl: http://msgroups.net/microsoft.public.word.vba.general/Using-an-array-with-spaces
|
Pages: 1 Prev: set hanging indent for second TOC Next: Imbedding a document in word |