Run time error 1004 during importing .bas file using VBA code
Hi I am facing a problem during importing a .bas file inside my excel file using Vba code this is my code
Sub importModuleBas()
Dim wb As Workbook
Dim strTemp As String
sPath = "D:\Users\dheeraj.kumar\Desktop\New folder\"
sourseFile = sPath & "Projec.xlsm"
strTemp = sPath & "TransModule.bas"
Set wb = Workbooks.Open(sourseFile )
wb.Activate
wb.VBProject.VBComponents.Import (strTemp)
'Kill (strTemp)
wb.Close
End Sub
During this I am Obtaining run time 1004 error if you have any idea then please help me
Note :Basically I want to export a module from workbook to another workbook using VBA
Note : this error is also known as
Sub importModuleBas()
Dim wb As Workbook
Dim strTemp As String
sPath = "D:\Users\dheeraj.kumar\Desktop\New folder\"
sourseFile = sPath & "Projec.xlsm"
strTemp = sPath & "TransModule.bas"
Set wb = Workbooks.Open(sourseFile )
wb.Activate
wb.VBProject.VBComponents.Import (strTemp)
'Kill (strTemp)
wb.Close
End Sub
During this I am Obtaining run time 1004 error if you have any idea then please help me
Note :Basically I want to export a module from workbook to another workbook using VBA
Note : this error is also known as
Programmatic access to Visual Basic Project is not trusted during importing .bas file from specified location
Hey I got solution of this question there is not any problem inside code but also before operating such type of Operation we have to follow some setting steps inside Excel Setting- Open the 2007 Microsoft Office system application in question. Click the Microsoft Office button, and then click Application Options
- Click the Trust Center tab, and then click Trust Center Settings.
- Click the Macro Settings tab, click to select the Trust access to the VBA project object model check box, and then click OK.
- Click OK.
After following these steps You got perfect solution as I got
Ok thank you
Happy Coding !
Comments
Post a Comment