Results 1 to 13 of 13

Thread: [RESOLVED] Combo box

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Resolved [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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Combo box

    Is this VB6 or Excel VBA?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Re: Combo box

    It's VBA

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    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.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Combo box

    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
    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

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    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.

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    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

  10. #10
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    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?

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    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
  •  



Click Here to Expand Forum to Full Width