2013-01-18 50 views

回答

3

如果您需要改變一個給定的工作表中的圖像的位置,你可以使用這樣的事情:

ActiveSheet.Shapes.Range(Array("Picture 1")).Select 
Selection.ShapeRange.IncrementLeft 100 

您可以通過更改.Increment ...命令的參數來調整運動的方向和運動量,例如爲圖像設置動畫。

2

如果我們要快速和骯髒的,需要以下工作表之間移動

Sub CutAndPasteAPicture(shapeName As String, fromSheet As String, toSheet As String, toRange As String) 
'Cut and Paste 
Sheets(fromSheet).Shapes(shapeName).Cut 
Sheets(toSheet).Paste Sheets(toSheet).Range(toRange) 
End Sub 

Sub Example() 
    CutAndPasteAPicture "Picture 1", "Sheet1", "Sheet2", "D2" 
End Sub 
2

又如:垂直移動一個圖像與特定行

Sheets(1).Shapes("Picture 1").Top = Sheets(1).Rows(24).Top 
0

這裏排隊是代碼到第一插入圖像到Excel,然後調整或調整圖片。稍後將圖片向下或向右移動

'Insert the Picture from the path if its not present already 

Set myPict = Thisworkbook.sheets(1).Range("A1:B5").Parent.Pictures.Insert(ThisWorkbook.Path & "\" & "mypic.jpg") 

'Adjust the Picture location 
    myPict.Top = .Top 
    myPict.Width = .Width 
    myPict.Height = .Height 
    myPict.Left = .Left 
    myPict.Placement = xlMoveAndSize 
    'myPict.LockAspectRatio = msoTriStateMixed 

'Change the width of the Picture 
    myPict.Width = 85 
'change the Height of the Picutre 
    myPict.Height = 85 
End With 

'Select the Picutre 
myPict.Select 

'Move down the picture to 3 points. Negative value move up 

Selection.ShapeRange.IncrementTop 3 


'Move towards right upto 5 points. Negative value moves towards right 
Selection.ShapeRange.IncrementLeft 5 
相關問題