Closed Thread
Results 1 to 3 of 3

Exporting VB Forms Automatically

  1. #1
    aVBgrad
    Guest

    Exporting VB Forms Automatically

    I am trying to export several Forms that I have created using VBEditor. I am
    not aware if this is possible or the correct syntax to export the form to a
    text file and then upload the form to another worksheet automatically. I
    have approximately 40+ spreadsheets that need to have the same form in each
    file. I have done this successfully with Modules but not with Forms. Is it
    possible to export and import automatically? Here is a sample of the syntax
    that I used for the modules......

    With Workbooks(RollUpProg)
    FName = .Path & "\code.txt"
    .VBProject.VBComponents("InventoryWalk2").Export FName
    End With
    Workbooks(datafilename).VBProject.VBComponents.Import FName

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello aVBgrad,

    The syntax is almost identical to importing or exporting a module. Just change UserForm1 to the form name you are using. The file name must end in .frm

    'This code must be run from the Workbook the Forms are in to be exported.
    With Workbooks(RollUpProg)
    FName = .Path & "\Test Form.frm"
    .VBProject.VBComponents("UserForm1").Export FName
    End With

    'This code must be run from the Workbook that it is in to import the form.
    Workbooks(datafilename).VBProject.VBComponents.Imp ort FName

    Sincerely,
    Leith Ross

  3. #3
    aVBgrad via OfficeKB.com
    Guest

    Re: Exporting VB Forms Automatically

    Thanks....that did the trick. But do you know how to remove or delete a from.
    I can do this with a module but am having issues with a Form. Here is the
    syntaxt I use for a module

    Set VBComp = Workbooks(RollUpProg).VBProject.VBComponents("UserForm1")
    ActiveWorkbook.VBProject.VBComponents.Remove VBComp


    Leith Ross wrote:
    >Hello aVBgrad,
    >
    >The syntax is almost identical to importing or exporting a module. Just
    >change UserForm1 to the form name you are using. The file name must end
    >in .frm
    >
    >'This code must be run from the Workbook the Forms are in to be
    >exported.
    >With Workbooks(RollUpProg)
    >FName = .Path & "\Test Form.frm"
    >.VBProject.VBComponents("UserForm1").Export FName
    >End With
    >
    >'This code must be run from the Workbook that it is in to import the
    >form.
    >Workbooks(datafilename).VBProject.VBComponents.Imp ort FName
    >
    >Sincerely,
    >Leith Ross
    >


    --
    Message posted via OfficeKB.com
    http://www.officekb.com/Uwe/Forums.a...mming/200512/1

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1