2016-09-01 4 views
0

VBAコードを使用して、選択したオブジェクトをパワーポイントに複製したいとします。私は以下のコードに言及していますvbaを使ってパワーポイント内のオブジェクトを複製しますか?

Sub CopySizeAndPosition() 

    ' Usage: Select two shapes. The size and position of 
    ' the first shape selected will be copied to the second. 

    Dim w As Double 
    Dim h As Double 
    Dim l As Double 
    Dim t As Double 

    With ActiveWindow.Selection.ShapeRange(1) 
     w = .Width 
     h = .Height 
     l = .Left 
     t = .Top 
    End With 
    With ActiveWindow.Selection.ShapeRange(2) 
     .Width = w 
     .Height = h 
     .Left = l 
     .Top = t 
    End With 
End Sub 

しかし、私はオブジェクトの値を取得する代わりに私の値を指定します。ですから、事前にお手伝いしてください!

+0

がないことを確認私はあなたが達成しようとしているのか理解は、 '、.Width''の値を入力します。高さなど? 200,100ほど? –

+0

はい、@ ShaiRado、あなたはどんな解決策もありますか、それは非常に役に立ちます。 –

+0

既存の図形をコピーして同じスライドに貼り付け、そのプロパティを変更しますか?またはあなたの値で既存の形状プロパティを変更するだけですか? –

答えて

2

あなたはこのようなあなたの値を設定することができ、あなたは、単一の図形を選択していると仮定:

' Sets the size and position of the first shape in a selection 
Sub SetShapeSizeAndPosition() 
    With ActiveWindow.Selection.ShapeRange(1) 
    .Width = 100 
    .Height = 100 
    .Left = 100 
    .Top = 100 
    End With 
End Sub 
関連する問題