|
-
Apr 10th, 2008, 09:01 AM
#1
Thread Starter
Lively Member
[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.
-
Apr 10th, 2008, 09:05 AM
#2
Re: Combo box
Is this VB6 or Excel VBA?
-
Apr 10th, 2008, 09:10 AM
#3
Thread Starter
Lively Member
-
Apr 10th, 2008, 09:15 AM
#4
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
-
Apr 10th, 2008, 09:20 AM
#5
Thread Starter
Lively Member
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
Last edited by Kubull; Apr 15th, 2008 at 05:18 AM.
-
Apr 12th, 2008, 11:10 PM
#6
Re: Combo box
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 14th, 2008, 03:01 AM
#7
Thread Starter
Lively Member
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.
-
Apr 14th, 2008, 04:28 AM
#8
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 15th, 2008, 05:44 AM
#9
Thread Starter
Lively Member
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
-
Apr 15th, 2008, 07:23 AM
#10
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 15th, 2008, 09:59 AM
#11
Thread Starter
Lively Member
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?
-
Apr 15th, 2008, 04:33 PM
#12
Re: Combo box
show the content of your text file, or attach the file
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 21st, 2008, 07:20 AM
#13
Thread Starter
Lively Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|