SSブログ

Excel2000 VBA アクティブブックのファイル名、モジュール名などMsgBoxに表示 [Excel2000 VBA独習]

Excel2000 VBA アクティブブックのファイル名、モジュール名などMsgBoxに表示

excel_VBA_bookinfo02.jpg

Sub book_info_2()
'book情報をMSGBOXに表示
'フルパス、ファイル名、ファイルサイズ、シート名一覧、プロジェクト数、モジュール名

On Error GoTo error_end
    Dim sheet_name, dataStr As String
    Dim i As Integer
    Dim sheet_list As String
    Dim book_path As String
    Dim book_name As String
    Dim book_fullname As String
    Dim book_size As Double
    Dim kaigyou As String
    Dim kaigyou2 As String
    Dim book_path_name As String
    Dim VBcop_count As Integer
    Dim moduleName As Variant
    Dim module_name_2 As Variant

'kaigyou = Chr(13) + Chr(10)                      '改行
    kaigyou = vbCrLf
'kaigyou2 = Chr(13) + Chr(10) + Chr(13) + Chr(10)  '2回改行
    kaigyou2 = vbCrLf + vbCrLf

'シート名リストの作成 sheet_name
    For i = 1 To Worksheets.count                    'Worksheets.Count ワークシート数
        sheet_name = Worksheets(i).Name
        sheet_list = sheet_list + sheet_name + kaigyou 'シート名の後に改行コードを追加する
    Next i

'Book名の取得
    book_name = ActiveWorkbook.Name
'bookフルパス名
'book_fullname = ActiveWorkbook.FullName
    book_path = ActiveWorkbook.Path
    book_path_name = book_path + "\" + book_name
'book ファイルサイズ
    book_size = FileLen(book_path_name)
'book VBプロジェクトマクロ数
    VBcop_count = ActiveWorkbook.VBProject.VBComponents.count

'モジュール名
For Each moduleName In ActiveWorkbook.VBProject.VBComponents
  If (moduleName.Type = 1 Or moduleName.Type = 2) And moduleName.Name <> "VBE" Then
  i = i + 1
  module_name_2 = module_name_2 & vbCrLf & moduleName.Name
  End If
Next

'MSGBOXに表示
    dataStr = "Path" & kaigyou & book_path & kaigyou2 & "File名" & vbCrLf & book_name & kaigyou2 & "ファイルサイズ" & kaigyou & Format(book_size, "###,###") & " Byte" & kaigyou2 & "シート名リスト" & kaigyou & sheet_list & kaigyou2 & "VBProject数" & vbCrLf & VBcop_count & vbCrLf + vbCrLf & "モジュール名" & module_name_2

    MsgBox dataStr
error_end:
End Sub


タグ:Excel2000 VBA
nice!(0)  コメント(0)  トラックバック(0) 
共通テーマ:パソコン・インターネット

nice! 0

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

トラックバック 0

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。