-
[RESOLVED] Combo box
I'm creating a user form that links to net send, through Excel. The form consists of a combo box and a message box, I'd like to get the combo box to list groups IE IT Team - (Myself, and my team's network user names) All Staff - every member of the department. But I have no idea how to set up the combo box to display and activate the right groups.
I know the easy answer is to use net send groups, but Corporate red tape provents me, which is very frustrating.
Any help would be greatly appriciated.
-
Re: Combo box
Is this VB6 or Excel VBA?
-
Re: Combo box
-
Re: Combo box
Then your question needs to be in Office Development.
VB6 and VBA deal with combos and listboxs a bit differently so VB6 syntax probably wouldn't work for you. :)
Moved
-
Re: Combo box
Thanks,
This is what I've got so far, but as I need to refer retval =shell to the combo box and then populate the combo box with something.
Code:
Private Sub cmd_cancel_Click()
Unload Me
End Sub
Private Sub ComboBox1_Change()
End Sub
Private Sub CommandButton1_Click()
text1.Text = text1
retval = Shell("net send 'User name' " + text1.Text, 0)
End Sub
-
Re: Combo box
Quote:
text1.Text = text1
this seems a bit redundant like saying x = x
the default property of textbox is text
maybe what you want is text1.text = lstDocumentType.text
-
Re: Combo box
That code is for the message box, I haven't got an issue with that, that works fine, its creating groups for the combo box I'm having problems with.
-
Re: Combo box
does the code open the text file?
where is mytemplatefldr set, does the contained string end in backslash?
are you getting anything in the combobox?
is Me.lstDocumentType.AddItem DataLine your combobox?
or is it Me.ComboBox1.Clear
-
Re: Combo box
Sorry I didn't realise I put that in there, that code was a test I got from another Site didn't work to be honest. nothing appeared in the combobox, probably because I didn't know what to put in the text file, as I need the label of a group IE " IT Team" and then the list of 4 peoples ID.
Thanks for your help by the way
-
Re: Combo box
you can put whatever you like in the text file, if it is just a list of naems that is the simplest, but if you want to have subgroups, you could put each user with their group into the combobox like
jo smith (IT team)
up to you to decide what you want first, then how to get it to work
-
Re: Combo box
I've created a text file called User groups.txt. how would I use vb to add that into the Combo box, so that when I select say the 'IT Team', it would then send a message like "Oi!" to the 4 users listed in the .txt file?
-
Re: Combo box
show the content of your text file, or attach the file
-
Re: Combo box
Finally got it sorted, this works like a charm via an frm in Excel I just input the user ID's into an excel file and the script pulls it right off.
Code:
Private Sub cmdSend_Click()
Unload frmnetsend
Dim objShell As New WshShell
Dim objExec As WshExec
Dim strComputer As String
Dim strMessage As String
Dim ReadAll As String
strMessage = txtmessage
If cmbNames.Value = "IT Team" Then
Range("Testgroup").Select
ElseIf cmbNames.Value = "ITTEAM" Then
Range("ITTEAM").Select
ElseIf cmbNames.Value = "Secretaries" Then
Range("Secretaries").Select
ElseIf cmbNames.Value = "SeniorLegalSec" Then
Range("SeniorLegalSec").Select
ElseIf cmbNames.Value = "Lawyers" Then
Range("Lawyers").Select
ElseIf cmbNames.Value = "ALLSTAFF" Then
Range("AllSTAFF").Select
End If
Do While ActiveCell.Value <> ""
strComputer = ActiveCell.Value
Set objExec = objShell.Exec("Net Send " & strComputer & " " & strMessage)
Do While Not objExec.StdOut.AtEndOfStream
ReadAll = objExec.StdOut.ReadAll
Loop
ActiveCell.Offset(1, 0).Select
Loop
MsgBox ReadAll, vbInformation, "Net Send Results"
End Sub
Private Sub UserForm_Initialize()
With cmbNames
.AddItem "TestGroup"
.AddItem "IT Team"
.AddItem "Senior Legal Secretaries"
.AddItem "Secretaries"
.AddItem "Lawyers"
.AddItem "All Staff"
End With
End Sub