技術(shù) 點
- 技術(shù)
- 點
- V幣
- 點
- 積分
- 22850
|
推薦
發(fā)表于 2017-4-3 11:35:23
|
只看該作者
- Sub test()
- Dim C, sPh As String
- Dim s As String
- sPh = CreateObject("Shell.Application").BrowseForFolder(0, _
- "選擇文件夾,程序?qū)⒃撐募䦅A保存的模塊全部導(dǎo)入!", 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 "已導(dǎo)入:" & s
- End Sub
- '獲得導(dǎo)入模塊路徑名
- 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
- '導(dǎo)出模塊
- Sub SaveThisModule()
- Dim C, sPh As String
- Dim s As String
- sPh = CreateObject("Shell.Application").BrowseForFolder(0, _
- "選擇文件夾,程序?qū)⒈竟ぷ鞑镜乃心K導(dǎo)出至該文件夾!", 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 "已導(dǎo)出:" & s
- End Sub
復(fù)制代碼
供參考 |
|