• Using the VBE (Word 97)

    Author
    Topic
    #376327

    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.

    Viewing 1 reply thread
    Author
    Replies
    • #615898

      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.

      2cents

      • #615945

        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.

    • #615947

      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

      • #615963

        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.

        • #615974

          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

          • #615976

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

            • #615978

              Try it, it’s fun, but use DocProperties to load the combo box. –Sam

    Viewing 1 reply thread
    Reply To: Using the VBE (Word 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: