作者: bongbong3481 時間: 2018-3-8 22:14 標題: Excel VBA insert pictures 問題
想用excel VBA insert 2 張picture, 想做到既效果,系第2張insert 既相, 疊放系第1張相上面, 但一RUN個 PROGRAM, 2張相走晒位, 沒按預定既位置 SHOW 出黎, 有冇人知點解?
Sub test()
FilePath1 = "C:\Documents and Settings\lee\桌面\temp\0001.jpg"
FilePath2 = "C:\Documents and Settings\lee\桌面\temp\0002.jpg"
Call Module2.Insert_Pic_From_File1(FilePath1, "A1", "A1", "A39", "K39")
Call Module2.Insert_Pic_From_File1(FilePath2, "A15", "A15", "A20", "K39")
End Sub
Sub Insert_Pic_From_File1(FilePath, Top_P, Left_P, Height_P, width_P)
Set Pic = Sheet1.Pictures.Insert(FilePath)
Pic.Name = "myPicture"
Set Shp = Sheet1.Shapes("myPicture")
With Shp
.LockAspectRatio = msoFalse
.Placement = 3
.Top = Range(Top_P).Top
.Left = Range(Left_P).Left
.Height = Range(Height_P).Top - Range(Top_P).Top
.width = Range(width_P).Left - Range(Height_P).Left
End With
End Sub
作者: evil666 時間: 2018-3-9 10:28
Sub Insert_Pic_From_File1(FilePath, Top_P, Left_P, Height_P, width_P)
Set pic = ActiveSheet.Pictures.Insert(FilePath)
'Pic.Name = "myPicture"
'Set Shp = Sheet1.Shapes("myPicture")
Set Shp = ActiveSheet.Shapes(pic.Name) <----------
With Shp
.LockAspectRatio = msoFalse
.Placement = 3
.Top = Range(Top_P).Top
.Left = Range(Left_P).Left
.Height = Range(Height_P).Top - Range(Top_P).Top
.Width = Range(width_P).Left - Range(Height_P).Left
End With
End Sub
作者: bongbong3481 時間: 2018-3-9 20:12
回覆 2# evil666
得左, 唔該晒
