Excel2000 VBA コメントの作成(背景画像有り無し) [Excel2000 VBA独習]
Excel2000 VBA コメントの作成(背景画像有り無し)
参考にしたサイト ttp://officetanaka.net/excel/vba/tips/tips120.htm
Sub 背景画像とコメント作成()
'
'コメントの設定と背景画像の設定
'実験未完成
'
Dim myINbox As Variant
Dim FL As Variant
Dim openFileName As Variant
Dim buf As Variant
Dim IMG As Object
'アクティブセルにコメントが設定されているかチェック、コメントが設定されている場合は終了
Set buf = Selection.Comment
If TypeName(buf) = "Comment" Then GoTo owari
'コメント文字取得
myINbox = Application.InputBox(Title:="コメント", prompt:="コメント文字列を入力", Type:=2)
'画像パス FL=1 背景画像有り FL=0 背景画像無し
openFileName = Application.GetOpenFilename("画像ファイル,*.*")
If openFileName <> "False" Then FL = 1 Else FL = 0
'コメントセットSet IMG = LoadPicture(openFileName) 訂正 削除
Select Case FL
Case 1
Set IMG = LoadPicture(openFileName) 追加
With ActiveCell.AddComment
.Shape.Fill.UserPicture openFileName
.Shape.Height = Application.CentimetersToPoints(IMG.Height) / 1000 '表示サイズ
.Shape.Width = Application.CentimetersToPoints(IMG.Width) / 1000
.Text myINbox
.Visible = True
End With
Case 0
With ActiveCell.AddComment
.Text myINbox
.Visible = True
End With
End Select
'追加
Set buf = Nothing
Exit Sub
owari:
Set buf = Nothing
MsgBox "コメントが設定されています。コメントを削除してから設定してください。"
End Sub
Excel でコメント欄に背景画像を設定するには
- 「コメントの書式」 を表示
- 色と線のタブで「塗りつぶし」色で下の「塗りつぶし効果」を選択
- 図の選択で画像を指定
コメント 0