HELP!我无法在任何地方找到这个...我已经找到了很多关于.frx文件的解释,但这不是问题。我已经出口了2个模块" .bas"和用户形式" .frm"这也创造了" .frx"二进制文件。问题是,现在当我使用下面的代码将它们导入到新工作簿时,在初始化用户窗体时,应用程序打开并尝试在原始工作簿中运行,我在其中编写模块并设计自定义用户窗体。为什么会发生这种情况,是否有办法让它在工作簿中加载导入表单和模块的用户窗体?
Sub Import_VBA(WBName)
Dim VBc As Variant
Dim exportFolder As String, VBcExt As String, testFile As String
Dim newWB As Workbook
testFile = WBName
exportFolder = "y:\ECI\Database\Outputs\InterfaceApp"
Set newWB = Workbooks(testFile & ".xlsm")
''''' Test VBA protection
On Error Resume Next
If newWB.VBProject.Protection <> 0 Then
If Err.Number = 1004 Then
Err.Clear
MsgBox "VBA Project Object Model is protected in " & newWB.Name & vbCrLf _
& vbCrLf & "Please remove VBA protection in Trust Center to continue.", _
vbExclamation + vbOKOnly, "Error"
Set newWB = Nothing
Exit Sub
Else
MsgBox Err.Number & ": " & Err.Description, vbExclamation, "Error"
Set newWB = Nothing
Err.Clear
Exit Sub
End If
End If
''''' Add Interface App Components
For Each VBc In CreateObject("Scripting.FileSystemObject").GetFolder(exportFolder).Files
Select Case LCase(Right(VBc.Name, 4))
Case ".bas", ".frm", ".cls", ".frx"
newWB.VBProject.VBComponents.Import exportFolder & "\" & VBc.Name
End Select
Next VBc
End Sub