Tuesday, March 11, 2014

How to import or remove a .frm file into your VBA project?

Sub to_import()
Application.VBE.ActiveVBProject.VBComponents.Import "c:\temp\myform.frm"
End Sub

Sub to_remove()
Application.VBE.ActiveVBProject.VBComponents.Remove Application.VBE.ActiveVBProject.VBComponents("Userform1")
End sub

P.S: Before running please allow the macro to change its own script, on "Macro Security".
Check the following option: "Trust access to the VBA Project object model".


No comments: