VB help required, is there a max column width for VB in Word 2003?

A

ArcticWolf

Hi,

I have a word doc where I've managed to use the 'VB' where I can add more
than 25 drop down items, I've managed to add around 70 with no probs so all
is good there.
However, when I try and add more items to the list it gives me an error,
"Compile Error: Expected: list separator or )" It won't let me complete my
next entry as it looks as though I've run out of room in the VB window. In
the toolbar at the top it says, "Ln7, Col 1024" and I can't add any more text
to that line. When I press enter (to continue the list on a new row) all my
entries go red and errors again.
How can I continue adding to my list or am I max'd out at Col 1024?

The VB code I'm trying to use is below, and I have another 150+ to add. My
list is basically a listing of all countries so the end user can select the
most appropiate one from a drop down list.

TIA,

AW


Private Sub UserForm_Initialize()

ComboBox1.ColumnCount = 1

'Load data into ComboBox

ComboBox1.List() = Array("Afghan", "Albanian", "Algerian", "American",
"American Samoan", "Andorran", "Angolan", "Anguillan", "Antiguan",
"Argentine", "Armenian", "Aruban", "Australian", "Austrian", "Azerbaijani",
"Bahamian", "Bahraini", "Bangladeshi", "Barbadian", "Barbudan", "Basotho",
"Belarusian", "Belgian", "Belizean", "Beninese", "Bermudian", "Bhutanese",
"Bolivian", "Bosnian", "Brazilian", "British", "British Virgin Islander",
"Bruneian", "Bulgarian", "Burkinabe", "Burmese", "Burundi", "Cambodian",
"Cameroonian", "Canadian", "Cape Verdean", "Caymanian", "Central African",
"Chadian", "Channel Islander", "Chilean", "Chinese", "Christmas Islander",
"Chuukese", "Cocos Islander", "Colombian", "Comoran", "Congolese", "Cook
Islander", "Costa Rican", "Croatian", "Cuban", "Cypriot", "Czech", "Danish",
"Djiboutian", "Dominican", "Dutch", "Dutch Antillean", "Ecuadorian",
"Egyptian", "Emirati", "Equatorial Guinean", "Eritrean", "Estonian",
"Ethiopian", "Falkland Islander", "Faroese", "Fijian", "Finnish")

End Sub
 
J

Jean-Guy Marcil

ArcticWolf was telling us:
ArcticWolf nous racontait que :
Hi,

I have a word doc where I've managed to use the 'VB' where I can add
more than 25 drop down items, I've managed to add around 70 with no
probs so all is good there.
However, when I try and add more items to the list it gives me an
error, "Compile Error: Expected: list separator or )" It won't let
me complete my next entry as it looks as though I've run out of room
in the VB window. In the toolbar at the top it says, "Ln7, Col 1024"
and I can't add any more text to that line. When I press enter (to
continue the list on a new row) all my entries go red and errors
again.
How can I continue adding to my list or am I max'd out at Col 1024?

The VB code I'm trying to use is below, and I have another 150+ to
add. My list is basically a listing of all countries so the end user
can select the most appropiate one from a drop down list.

TIA,

AW


Private Sub UserForm_Initialize()

ComboBox1.ColumnCount = 1

'Load data into ComboBox

ComboBox1.List() = Array("Afghan", "Albanian", "Algerian",
"American", "American Samoan", "Andorran", "Angolan", "Anguillan",
"Antiguan", "Argentine", "Armenian", "Aruban", "Australian",
"Austrian", "Azerbaijani", "Bahamian", "Bahraini", "Bangladeshi",
"Barbadian", "Barbudan", "Basotho", "Belarusian", "Belgian",
"Belizean", "Beninese", "Bermudian", "Bhutanese", "Bolivian",
"Bosnian", "Brazilian", "British", "British Virgin Islander",
"Bruneian", "Bulgarian", "Burkinabe", "Burmese", "Burundi",
"Cambodian", "Cameroonian", "Canadian", "Cape Verdean", "Caymanian",
"Central African", "Chadian", "Channel Islander", "Chilean",
"Chinese", "Christmas Islander", "Chuukese", "Cocos Islander",
"Colombian", "Comoran", "Congolese", "Cook Islander", "Costa Rican",
"Croatian", "Cuban", "Cypriot", "Czech", "Danish", "Djiboutian",
"Dominican", "Dutch", "Dutch Antillean", "Ecuadorian", "Egyptian",
"Emirati", "Equatorial Guinean", "Eritrean", "Estonian", "Ethiopian",
"Falkland Islander", "Faroese", "Fijian", "Finnish")

End Sub

The error message you receive is usually seen because a quote or a comma is
missing in a String definition.

However, I have never tried writing such a long string in the VBA editor.
It appears that the limit of character on one line is 1024 characters....

So, you should learn to use the end of line character that allows you to
have a long command on many lines. I usually limit each line to something
between 60 and 80 characters. It makes the code easier to read and to
manage.
Basically, all you need to do is use the "space-underscore" sequence at the
end of a line to tell the compiler that the actual command line continues
onto the next line. Your code would then look like something like this:

ComboBox1.List() = Array("Afghan", "Albanian", "Algerian", "American", _
"American Samoan", "Andorran", "Angolan", "Anguillan", "Antiguan", _
"Argentine", "Armenian", "Aruban", "Australian", "Austrian",
"Azerbaijani", _
"Bahamian", "Bahraini", "Bangladeshi", "Barbadian", "Barbudan",
"Basotho", _
"Belarusian", "Belgian", "Belizean", "Beninese", "Bermudian",
"Bhutanese", _
"Bolivian", "Bosnian", "Brazilian", "British", "British Virgin
Islander", _
"Bruneian", "Bulgarian", "Burkinabe", "Burmese", "Burundi", "Cambodian",
_
"Cameroonian", "Canadian", "Cape Verdean", "Caymanian", "Central
African", _
"Chadian", "Channel Islander", "Chilean", "Chinese", "Christmas
Islander", _
"Chuukese", "Cocos Islander", "Colombian", "Comoran", "Congolese", _
"Cook Islander", "Costa Rican", "Croatian", "Cuban", "Cypriot", "Czech",
_
"Danish", "Djiboutian", "Dominican", "Dutch", "Dutch Antillean", _
"Ecuadorian", "Egyptian", "Emirati", "Equatorial Guinean", "Eritrean", _
"Estonian", "Ethiopian", "Falkland Islander", "Faroese", "Fijian", _
"Finnish")
 
A

ArcticWolf

Merci beaucoup, il a travaillé parfaitement. Merci également de la réponse
rapide :)
 
J

Jean-Guy Marcil

ArcticWolf was telling us:
ArcticWolf nous racontait que :
Merci beaucoup, il a travaillé parfaitement. Merci également de la
réponse rapide :)

Content d'avoir pu vous aider!
 
Top