Results 1 to 9 of 9
  1. #1
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Copying a Form (VB 6)

    This may be a dumb question, but darned if I can find a way to make a duplicate of an existing form and simply give it a new name. I assumed there would be a copy and paste (with Save As), but I can't find it.

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

    Re: Copying a Form (VB 6)

    One possibility is to save the form under another name (File | Save As), then add the original form to your project (Project menu)

  3. #3
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Copying a Form (VB 6)

    I'll give it a shot.

  4. #4
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Copying a Form (VB 6)

    In the Project Explorer window (within the VBEditor), you can drag a UserForm from one project to another (and the result is that a copy of the form gets created in the target project, rather than that the form gets moved). At that point you could presumably rename the copy, then drag the renamed copy to the original project.

    HOWEVER, I've run into major corruption problems in the course of trying to rename forms within a single project if the new name is a name that another form (or a deleted form) used to have in the same project. What you'd be doing isn't the same thing, but I'm now paranoid in this area so I'd be cautious. I'd probably make a backup copy of the project first. Then, after doing the original form copy and renaming the copy, I'd probably exit out of both projects and out of Word. Then I'd restart Word and do the 2nd copy (of the renamed form to the original project).

    I just realized maybe you're working with standalone VB rather than VBA within Word, in which case I don't know to what extent any of the above would apply.

  5. #5
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Copying a Form (VB 6)

    You guessed right -- I'm working on a stand-alone VB 6.0 project. The solution I came up with isn't very elegant, but it works. First i created a new blank form, sized it the same as the form I wanted to copy. Then I selected and copied all the objects in the original form and pasted them into the new form. Then did the same with the VB code. So I end up with a new form with basically the same objects and code. After thai, of course, I had to go in and modify the code and make any other changes I needed on the new form.

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

    Re: Copying a Form (VB 6)

    I've had no problems exporting a module, renaming it outside of VB, then importing it again.

    Alan

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

    Re: Copying a Form (VB 6)

    With forms it's a bit different: you'd have to rename both the .frm and the .frx file. Also, the .frm file (which is actually a plain text file) contains two instances of the name of the form, you'd have to change those in a text editor. You can then import the renamed .frm file.

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

    Re: Copying a Form (VB 6)

    You're right of course Hans. And I forgot to mention those vital facts w.r.t Forms c.f. .BAS modules. <img src=/S/sorry.gif border=0 alt=sorry width=15 height=15> Chuck.
    That said though, the search/ replace is a simple task, as is renaming the two associated files.

    Alan

  9. #9
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Copying a Form (VB 6)

    Alan and Hans
    Thank you both. I got myself wrapped around the post on this problem last week.
    Regards
    Don

Posting Permissions

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