EXCEL VBA 如何檢查userform1.image.picture 有沒有圖

2006-12-12 11:27 pm
如何檢查userform1.image.picture 有沒有圖
我試過
if userform1.image.picture = 0 then
or
if userform1.image.picture = null then

都出以下error
"沒有設定物件數或With 區塊變數"


請指教

回答 (2)

2006-12-17 6:14 pm
✔ 最佳答案

圖片參考:http://hk.yimg.com/i/icon/16/1.gif
下面是一個例子:

Return "no Picture Found" If There Is Not One Avaliable

Sub Copy_Cells()

'Copying the row
addr = ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address
Intersect(Range(addr).EntireRow, Range("b:ak")).Select
Selection.Copy Sheet2.Range("b65536").End(xlUp).Offset(0, 0)
Sheets("sheet3").Select

'Picture code
MyPicturesName = Sheets("sheet3").Range("i5").Text

'Allow "no picture found" error
On Error Resume Next

Sheets("sheet1").Shapes(MyPicturesName).Copy
Sheets("sheet3").Range("c3").Select

'Check if error
If Err <> 0 Then
'Was error
ActiveCell = "Sorry no picture found."
'Reset Err
Err = 0
Else
'Picture found
ActiveSheet.Paste
End If

Range("a1").Select

'hide tabs
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Visible = False

End Sub
2006-12-14 8:27 pm
if userform1.image.picture is nothing then ......


收錄日期: 2021-04-23 19:16:01
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20061212000051KK01809

檢視 Wayback Machine 備份