Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Sep 2002
    Location
    Detroit, Michigan, USA
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using the VBE (Word 97)

    I intend to populate a combobox upon loading (or initialisation) of a certain user form with the .AddItem method of the box control. Now, the initial list of possible options will be saved with the project but the user should be able to add new entries for future use. In order to prevent that those entries be lost the next time the project is started I need to save them to the actual project through the VBE. Now....how is it done?. Thanks in advance.

  2. #2
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using the VBE (Word 97)

    I don't think there's a way to do what you propose. I think you might want to do it another way. Maybe have the program write/read to another document that contains the elements of the combobox, or maybe write the elements to the current document but "hidden" somehow.

    <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15>

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using the VBE (Word 97)

    It's possible to modify the code, but that's the wrong way to do this.

    If one needs to change the content of lists or combo boxes or, whatever, based on user input, and then have those values available for future use, the right way is to initialize such controls by grabbing input from database, ini files, Word template, Registry.

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Using the VBE (Word 97)

    Depending on the type of entries, it may be appropriate to store them as Document Variables.

    Are they document specific? User specific? PC Specific?

    StuartR

  5. #5
    Star Lounger
    Join Date
    Sep 2002
    Location
    Detroit, Michigan, USA
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using the VBE (Word 97)

    The way I see it...it should not be neither PC nor application specific. Once you set up a reference to the Extensibility library, you have access to the actual code through code (go figure...). Saving extra entries to that combobox should be just as easy and usual as saving, for example color settings... . Reading data off an external file could work but still implies opening, reading and closing via automation, a real overkill if any. I'm positive about the use of VBE ..all I need to know is how to implement it...
    Thanks again.

  6. #6
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using the VBE (Word 97)

    You REALLY do not want to do this, but it is fun & frustrating to learn. If you insist, the place to start is Chip Pearson's Programming to the VBE. Yes, I know, this stuff is for Excel, but it is pretty easy to translate: just change ThisWorkbook to ThisDocument and I think that the rest is the same. After trying Chip's stuff, you are really on your own. I've not seen much other useful material.

    BUT, what you really want to do is what Stuart suggested, just store the combo box entries as CustomDocumentProperties. If you do a search on the lounge, you will find some sample code. HTH --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  7. #7
    Star Lounger
    Join Date
    Sep 2002
    Location
    Detroit, Michigan, USA
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using the VBE (Word 97)

    I checked Wrox's Excel 200 VBA Programmer's reference...has a long chapter on it....still....
    Thanks anyway....

  8. #8
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using the VBE (Word 97)

    Try it, it's fun, but use DocProperties to load the combo box. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

Posting Permissions

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