返回列表 上一主題 發帖

請教關於圖片顯示的語法?

回復 1# tku0216
移動滑鼠點選  儲存格上 有圖片檔案名稱  會顯示 該檔案名稱的圖片
  1. Private Sub Worksheet_SelectionChange(ByVal Target As Range)   '該工作表的事件 程序
  2.     Dim xPath As String
  3.     On Error Resume Next
  4.     xPath = "d:\"                                       '修改為圖片檔 的路徑資料夾
  5.     [xlTarget].ClearComments
  6.     If Target(1) = "" Then Exit Sub
  7.     If Dir(xPath & Target) = "" Then Exit Sub
  8.     Target.Name = "xlTarget"
  9.     [xlTarget].NoteText " "
  10.     With Target.Comment.Shape           '儲存格註解文字圖案
  11.         .TextFrame.Characters.Font.ColorIndex = 1
  12.         .TextFrame.Characters.Font.Size = 14
  13.         .Fill.ForeColor.SchemeColor = 13
  14.         .AutoShapeType = msoShapeRectangle
  15.         .Line.ForeColor.SchemeColor = 53
  16.         .Line.Weight = 2
  17.         .Fill.UserPicture xPath & Target
  18.         .ScaleWidth 4, 0
  19.         .ScaleHeight 3, 0
  20.         .Visible = True
  21.     End With
  22. End Sub
複製代碼
如圖
   

TOP

回復 5# softsadwind
移動滑鼠點選  儲存格上 有圖片檔案名稱  會顯示註解背景圖案為該檔案名稱的圖片
儲存格 的資料為一完整的路徑檔案名稱(圖片檔)
  1. Option Explicit
  2. Private Sub Worksheet_SelectionChange(ByVal Target As Range)   '該工作表的事件 程序
  3.     Dim xPath As String
  4.     On Error Resume Next
  5.     [xlTarget].ClearComments                            '清除 工作表範圍 xlTarget 註解
  6.     On Error GoTo 0
  7.     If Target(1) = "" Then Exit Sub
  8.     xPath = Dir(Target(1))                              '查詢 儲存格資料是否傳回一檔案
  9.     If xPath <> "" Then
  10.         xPath = Target(1)
  11.     Else
  12.         xPath = "http://forum.twbts.com/templates/discuz6/images/logo.gif"  
  13.     End If
  14.     Target.Name = "xlTarget"
  15.     [xlTarget].NoteText " "
  16.     With Target.Comment.Shape                           '儲存格註解文字圖案
  17.         .AutoShapeType = msoShapeRectangle
  18.         .Line.ForeColor.SchemeColor = 53
  19.         .Line.Weight = 2
  20.         .Fill.UserPicture xPath                         '註解圖案 載入圖片
  21.         .Width = Target(1, 2).Resize(, 5).Width         '註解圖案 寬度
  22.         .Height = Target(1, 2).Resize(10).Height        '註解圖案 高度
  23.         .Visible = True
  24.     End With
  25. End Sub
複製代碼

TOP

回復 9# roy1221

TOP

        靜思自在 : 我們要做好社會的環保,也要做好內心的環保。
返回列表 上一主題