|
- Sub test()
- Dim C, sPh As String
- Dim s As String
- sPh = CreateObject("Shell.Application").BrowseForFolder(0, _
- "选择文件夹,程序将该文件夹保存的模块全部导入!", 0, 0).Self.Path
- For Each C In FileFullName(sPh)
- With Application.VBE.ActiveVBProject.VBComponents
- .Import C
- s = s + vbCrLf + C
- End With
- Next
- MsgBox "已导入:" & s
- End Sub
- '获得导入模块路径名
- Function FileFullName(sPath As String) As String()
- Dim iCt As Integer
- Dim TemAr() As String
- Dim sDir As String
- sDir = Dir(sPath & "" & "*.bas")
- While Len(sDir)
- ReDim Preserve TemAr(iCt)
- TemAr(iCt) = sPath & "" & sDir
- iCt = iCt + 1
- sDir = Dir
- Wend
- FileFullName = TemAr
- End Function
- '导出模块
- Sub SaveThisModule()
- Dim C, sPh As String
- Dim s As String
- sPh = CreateObject("Shell.Application").BrowseForFolder(0, _
- "选择文件夹,程序将本工作簿的所有模块导出至该文件夹!", 0, 0).Self.Path
- For Each C In ThisWorkbook.VBProject.VBComponents
- If C.Type = 1 Then
- Application.VBE.ActiveVBProject.VBComponents(C.Name).Export (sPh & "" & C.Name & ".bas")
- s = s + vbCrLf + C.Name
- End If
- Next
- MsgBox "已导出:" & s
- End Sub
复制代码
供参考 |
|