A
avkokin
Hello.
Sorry, but I unknow how I can access to all ComboBox on my form. So, I
have the template with UserForm. This UserForm has 5 combobox. All
combobox has different names. I need to fill all these combobox some
value from one table, aside from first combobox. How can I do it?
Thank you very much.
For example, I can fill my one combobox:
Private Sub UserForm_Initialize()
Dim Source As Document
Dim SourceTable As Table
Dim cmb As ComboBox
Dim i As Long
Dim s As String
'Fill the first combobox
cmbOrder.List = Array("One", "Two", "Three", "Next", "Five", "Zero")
'get values from the table
Set Source = Documents.Open("E:\Backup_copy\Sport\table.doc",
ReadOnly:=True, Visible:=False)
Set SourceTable = Source.Tables(1)
'Filling one from others 4 combobox
With Me.cmbFood1
For i = 1 To SourceTable.Columns(1).Cells.Count
s = SourceTable.Columns(1).Cells(i).Range.Text
.AddItem Left(s, Len(s) - 2)
Next i
End With
Source.Close
End Sub
Sorry, but I unknow how I can access to all ComboBox on my form. So, I
have the template with UserForm. This UserForm has 5 combobox. All
combobox has different names. I need to fill all these combobox some
value from one table, aside from first combobox. How can I do it?
Thank you very much.
For example, I can fill my one combobox:
Private Sub UserForm_Initialize()
Dim Source As Document
Dim SourceTable As Table
Dim cmb As ComboBox
Dim i As Long
Dim s As String
'Fill the first combobox
cmbOrder.List = Array("One", "Two", "Three", "Next", "Five", "Zero")
'get values from the table
Set Source = Documents.Open("E:\Backup_copy\Sport\table.doc",
ReadOnly:=True, Visible:=False)
Set SourceTable = Source.Tables(1)
'Filling one from others 4 combobox
With Me.cmbFood1
For i = 1 To SourceTable.Columns(1).Cells.Count
s = SourceTable.Columns(1).Cells(i).Range.Text
.AddItem Left(s, Len(s) - 2)
Next i
End With
Source.Close
End Sub