Fraser 的 excel 課堂分享
Fraser的office2007~excel課堂分享
2008年8月28日 星期四
註解裡顯示超鏈接的圖片
註解裡顯示超鏈接的圖片
(轉貼)
索 引
C0015
主 題
>= 12.0(Office 2007)
版 本
註解裡顯示超鏈接的圖片
說 明
本範例試範如何將圖片匯入註解中,及依圖片的大小來調整註解的尺寸。
參 考
Code
Private Sub
Worksheet_SelectionChange(
ByVal
Target
As
Range)
If
Target.Count > 2
Then
Exit Sub
Set
rng = Range("A3:A9")
'設定範圍
If
Union(rng, Target).Address = rng.Address
Then
'保留前一個 Target 儲存格
Static
chkrange
As
Range
'刪除前一個註解
If Not
chkrange
Is Nothing Then
chkrange.Comment.Delete
End If
Dim
cmt
As
Comment
Dim
jpgImg
As Object
Application.EnableEvents =
False
Set
chkrange = Target
Set
hasComment = Target.Comment
'判斷儲存格是否有註解
If
hasComment
Is Nothing Then
Set
cmt = Target.AddComment
Else
Set
cmt = Target.Comment
End If
'圖片填滿註解
fname = ThisWorkbook.Path & "\" & Target
'取得圖片的 高度及寬度
Set
jpgImg = CreateObject("WIA.ImageFile")
jpgImg.LoadFile fname
cmt.Shape.Fill.UserPicture fname
cmt.Shape.Height = jpgImg.Height
cmt.Shape.Width = jpgImg.Width
'顯示註解
Application.DisplayCommentIndicator = xlCommentIndicatorOnly
Application.EnableEvents =
True
End If
End Sub
Code
沒有留言:
張貼留言
‹
›
首頁
查看網路版
沒有留言:
張貼留言