Results 1 to 5 of 5
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Duplicating forms & controls (Word 2000)

    I'm in the process of developing a series of user forms, many of which are very similar. I also have similar groups of controls on individual forms. I'd like to be able to simply replicate/clone these forms and features, using copy/paste or similar.

    Are there any tricks to doing this? I seem to recall problems with numbering of controls, tab orders, confusion with control arrays... What's the best method for doing this kind of thing please?

    thanks

    Alan

  2. #2
    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: Duplicating forms & controls (Word 2000)

    I think that when you copy controls the names get genericized. For example, txtName becomes Textbox1. This prevents name conflicts, but it also means your event handlers no longer relate to the control names and you have to edit everything.

    As for tab orders and control arrays, I don't have any experience with that.

  3. #3
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    Location
    San Jose, California, USA
    Posts
    1,061
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating forms & controls (Word 2000)

    I do this a lot in my Excel projects when I have designed a form and want to have another similar one. My trick, such as it is, is to export the form from the VBE. Then I temporarily rename the current form from frmData (or whatever it is) to frmData1. Now I import the "old" copy of frmData (the one I just exported. Now I have two copies and then I just rename one of them again as needed.

    I use export feature to temporarily store a copy of the form I want to duplicate. That way I get all the code that goes with it, nothing is lost.

    Another way is to open a new, empty workbook. Now you have two workbooks open (this new empty one, and your original one). Now in the VBE, just drag the form from your original workbook to this empty one. Rename this form in that new workbook and then drag it back to your real workbook. Draggng between workbooks makes a copy, it doesn't move it.

    Deb <img src=/S/compute.gif border=0 alt=compute width=40 height=20>

  4. #4
    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: Duplicating forms & controls (Word 2000)

    Great trick. Actually, I don't think you have to edit the file. I've accidentally imported a userform that I hadn't removed, and VBE adds a 1 to the name to avoid duplication.

  5. #5
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating forms & controls (Word 2000)-MULTI-Re:

    Thanks Deb. I agree, neat trick, and I think perfect for my current project. I can create a generic ClientForm, export it, then import as required as Client1Form, Client2Form, ...

    I also like the reusability aspect, from project to project. Great tip, thanks.

    P.S. Sorry to post this as a Word query originally. Clearly, it belongs in VB/ VBA - lucky the moderators are sharper than me ;-)

    Alan

Posting Permissions

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