Excel VBA アクティブブックのファイル名などをMSGBOXに表示 [Excel2000 VBA独習]
Excel VBA アクティブブックのファイル名などをMSGBOXに表示
エラーがでたら修正する
Sub book_info()
'book情報をMSGBOXに表示
Dim sheet_name(255) 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 '追記 追加
'kaigyou = Chr(13) + Chr(10) '改行'kaigyou2 = Chr(13) + Chr(10) + Chr(13) + Chr(10) '2回改行
kaigyou = vbCrLf '追記 vbCrLf 改行
kaigyou2 =vbCrLf + vbCrLf
'シート名リストの作成 sheet_name
For i = 1 To Worksheets.Count 'Worksheets.Count ワークシート数
sheet_name(i) = Worksheets(i).Name
sheet_list = sheet_list + sheet_name(i) + kaigyou 'シート名の後に改行コードを追加する
Next i
'Book名の取得
book_name = ActiveWorkbook.Name
'bookフルパス名
'book_fullname = ActiveWorkbook.FullName
book_path = ThisWorkbook.Path '追記 ActiveWorkbook.Path に変更する必要があり
book_path_name = book_path + "\" + book_name
'book ファイルサイズ
book_size = FileLen(book_path_name)
'MSGBOXに表示
MsgBox "Path" & kaigyou & book_path & kaigyou2 & "File名" & kaigyou & book_name & kaigyou2 & "ファイルサイズ" & kaigyou & Format(book_size, "###,###") & " Byte" & kaigyou2 & "シート名リスト" & kaigyou & sheet_list
End Sub
VBAの練習でいろいろ作って、ファイルの管理がいい加減なので混乱中
コメント 0