AminShailja
New Member
- Joined
- Dec 2, 2019
- Messages
- 11
- Office Version
- 2010
- Platform
- Windows
- Web
Hello,
I am trying to import a .bas file into an Excel1. but it directly saves as a Class module, while I need it to be saved as a module or in as a Excel object.
Also when I try to run the module, it gives error.
Please help me with this.
Below is the code I am trying for it.
I am trying to import a .bas file into an Excel1. but it directly saves as a Class module, while I need it to be saved as a module or in as a Excel object.
Also when I try to run the module, it gives error.
Please help me with this.
Below is the code I am trying for it.
VBA Code:
Sub importfile1()
Dim VBProj As Object 'VBIDE.VBProject
Dim myFileName As String
Workbooks.Open ("File1")
myFileName = "importfile.bas"
'MsgBox (ActiveWorkbook.Name)
Set VBProj = Nothing
On Error Resume Next
Set VBProj = ActiveWorkbook.VBProject
On Error GoTo 0
If VBProj Is Nothing Then
MsgBox "Can't continue--I'm not trusted!"
Exit Sub
End If
VBProj.vbcomponents.Import myFileName
Application.Run ("'file2'!sheet11.Macro1")
End Sub
Last edited by a moderator: