+ Reply to Thread
Results 1 to 2 of 2

How to export userform and remove it before closing workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    05-01-2008
    Posts
    4

    How to export userform and remove it before closing workbook

    Hi,
    I have some weird method, I use the comment-out method to export and remove the userform in one computer, it works well and not runable in another one.
    While the non-comment-out method does not work.

    Who can help me fix it?

    Thanks!

    Hansell

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    
        Dim c As Worksheet
        Dim FileName As String
        Dim VBForm As Object
        Dim VBProj As Object
        
        FileName = "C:\Program Files\Microsoft Office\OFFICE11\MACROS\vbcomponent\UserForm1.frm"
        
        If (Dir(FileName) = "") Then
            Set VBProj = Application.VBE.ActiveVBProject
    '       the following set comand not workable
            Set VBForm = VBProj.VBComponents.Export(FileName)
            
            VBA.UserForms.Remove VBForm.Name
    '        the comment-out mehtod  work in one computer while not in another one.  
    '        ThisWorkbook.VBProject.VBComponents("frmModelInputs").Export FileName)
    '        ThisWorkbook.VBProject.VBComponents.Remove _
    '            ThisWorkbook.VBProject.VBComponents("frmModelInputs")
        End If
    
        ThisWorkbook.Save
    End Sub
    Last edited by royUK; 07-15-2008 at 10:58 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    hansell, please read the forum Rules & use code tags in future.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to 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