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
Bookmarks