Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    NJ, USA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combobox Values from Shared list (Word 2000)

    Hello,

    We have multiple templates that use a similar form, which includes a combobox for Client and Product Name. Is there any way that we can have the form load the available values for this list from a shared location, such as another Word document or Excel sheet, so that we only need to update the values in one location, and not within every template? I'm pretty new to all this, so detailed instructions would be appreciated! :-)

    Please let me know if you need any additional information on what it is we are trying to accomplish, and thanks in advance for any help!
    magella

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combobox Values from Shared list (Word 2000)

    You can use the good old ini file format for this. Say that you want to fill a combo box cbxProducts. Create a text file Settings.txt in a location where all users have read rights. Its contents should look like this:

    [Products]
    Count=3
    Item1=Monitor
    Item2=Keyboard
    Item3=Mouse

    If you like, you can add more sections like this in the same file. Fill the combo box in the Initialize ecvent of the userform:

    Private Sub UserForm_Initialize()
    Const strSettingsFile As String = "serversharefolderSettings.txt"
    Const strSection As String = "Products"
    Dim lngCount As Long
    Dim strItem As String
    Dim i As Long
    lngCount = System.PrivateProfileString(strSettingsFile, strSection, "Count")
    For i = 1 To lngCount
    cbxProducts.AddItem System.PrivateProfileString(strSettingsFile, strSection, "Item" & i)
    Next i
    End Sub

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Combobox Values from Shared list (Word 2000)

    I think the recommendation would depend on the relationships between these things (clients and products). If they are simply two completely separate lists, the method Hans describes (using a text file) should be the fastest and "lowest overhead." To read an Excel sheet or an Access database requires you to load additional program code into memory. The seconds that takes could be justified if you needed to structure your data in a more complicated way. For example, if you want to relate clients and products using a more efficient structure, or if you want that relationship reflected in your UserForm (e.g., selecting a client in one control dynamically updates a list in another control).

  4. #4
    Lounger
    Join Date
    Jan 2001
    Location
    NJ, USA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combobox Values from Shared list (Word 2000)

    Hello Hans - thank you, this is perfect! I really appreciate your help!

    magella

  5. #5
    Lounger
    Join Date
    Jan 2001
    Location
    NJ, USA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combobox Values from Shared list (Word 2000)

    Thank you for your suggestions, but it is very straightforward, so the method Hans posted works perfectly!

    Thanks,
    magella

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •