• Retrieving UserForm Properties (Office 2000 & later)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Retrieving UserForm Properties (Office 2000 & later)

    Author
    Topic
    #446634

    Hi All,

    I have an ‘applet’ I’ve developed as a UserForm in Excel, and I’d like to turn it into a stand-alone executable via VB. Other than referencing the MS Forms Object Library, I’m not using any Office-specific code – the form doesn’t even read or write anything to the worksheet and the code runs just as happily in Word. Since it seems I can’t simply convert a UserForm to a proper VB form, I was hoping I could extract the properties of all the (200+) controls on my userform and, perhaps, programatically re-create the beast using VB with the correct calls.

    Is either of these feasible? So far, I haven’t found a simple way to read all the control properties on my userform – it seems you have to know which properties go with which type of control before reading their values.

    Any ideas?

    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

    Viewing 1 reply thread
    Author
    Replies
    • #1086609

      You’d have to loop through the controls and use a Select Case to handle each type of control. It might be faster to recreate the form manually…

    • #1086615

      I may be missing something here, but I tried creating a UserForm in XL with a scattering of controls. I used Export File… to save it as UserForm1.frm. When I imported that into VB6, it appeared to be an exact replica. ???

      Alan

      • #1086617

        Too easy! rofl

      • #1086635

        Yes, but it does not become a native VB6 form, instead it shows up as a Designer object and does not have the same functionality as a native VB6 form. It does work however.

        • #1086680

          Hi Jan,

          Does that also mean the user would need to have MS Office installed to use it, since the vba version of the user form requires the MS Office Forms Object Library?

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

          • #1086694

            Well, the simplest check is to remove the reference to the forms lib from the project’s reference I guess?

            • #1086784

              Ah, but I can’t do that since I don’t have VB6 – yet – and I didn’t want to invest in it only to find I’m no better off!

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #1086793

              Well, the project I have -which contains an imported userform- has no reference to the msforms library. No idea if it runs without, because this is a tool directed at Excel anyway, so no sigar when Office isn’t on the machine anyway.

      • #1086637

        Hi Alan,

        I don’t have VB6 and was thinking more in terms of converting to VB.NET code and compiling that, for which I based my understanding on:
        http://msdn2.microsoft.com/en-us/library/a…office.11).aspx[/url]
        and
        http://msdn2.microsoft.com/en-us/library/a…office.11).aspx[/url]
        Maybe I should try to track down a copy of VB6. It seems that would make life easier.

        Cheers,
        Paul Edstein
        [Fmr MS MVP - Word]

        • #1086684

          I didn’t realize you needed to go as deep as the coding. The simple test I did only went as far as preserving the control properties/ attributes… then again, this might arguably be the most labour-intensive part of the conversion. ???

          Alan

          • #1086785

            Hi Alan,

            I’ve got 1500 lines of code attached to this form, so it would be important that the two would still work.

            I’ve managed to cobble together some code to extract the various control properties, but getting a complete listing will take a fair bit more effort. But then the as yet unanswered question becomes: can this then be translated into an equivalent set of VB6/VB.NET controls.

            Cheers,
            Paul Edstein
            [Fmr MS MVP - Word]

    Viewing 1 reply thread
    Reply To: Reply #1086684 in Retrieving UserForm Properties (Office 2000 & later)

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

    Your information:




    Cancel