08/03/03 18:53:27
VBAソースをいっぺんに吐き出すマクロ(Excel2003)
準備
・A列にファイルリストを作る
参考:URLリンク(www.vbalab.net)
・ツール→マクロ→セキュリティ→信頼できる発行元
のVBプロジェクトへのアクセスを信頼するをON
ext(1) = ".bas": ext(2) = ".cls": ext(3) = ".frm"
Set xl = CreateObject("Excel.application")
xl.Application.Visible = True
xl.AutomationSecurity = msoAutomationSecurityForceDisable 'マクロ無効
For i = 1 To 9999
bookName = Cell(i, 1)
If bookName = "" Then Exit For
Set bk = xl.Workbooks.Open(bookName, False, True)
With bk.VBProject.VBComponents
For j = 1 To .Count
If .Item(j).Type <= 3 Then _
.Item(j).Export bookName & "_" & .Item(j).Name & ext(.Item(j).Type) & ".txt"
Next
End With
bk.Close SaveChanges:=False
Next