Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://excel-egy.com/forum/t3797
- ---------------------------------
- Sub Copy_Module_To_Multiple_Closed_Workbooks()
- Dim wbkSource As Workbook
- Dim wbkTarget As Workbook
- Dim strFolder As String
- Dim strFile As String
- Dim strModule As String
- Application.ScreenUpdating = False
- Application.EnableEvents = False
- Set wbkSource = ThisWorkbook
- strFolder = wbkSource.Path & "\حساب\عملاء\"
- strModule = strFolder & "modHassona.bas"
- wbkSource.VBProject.VBComponents("modHassona").Export Filename:=strModule
- strFile = Dir(PathName:=strFolder & "*.xls*")
- Do While strFile <> ""
- Set wbkTarget = Workbooks.Open(Filename:=strFolder & strFile)
- With wbkTarget.VBProject.VBComponents
- On Error Resume Next
- .Remove VBComponent:=.Item("modHassona")
- On Error GoTo 0
- .Import Filename:=strModule
- End With
- wbkTarget.Close SaveChanges:=True
- strFile = Dir
- Loop
- Kill strModule
- Application.EnableEvents = True
- Application.ScreenUpdating = True
- MsgBox "Done...", 64
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement