2

私ができる必要があるのは、上向き矢印の文字を見つけて上向き矢印の形に置き換え、下向き矢印に対して同じことを行うことです。私は VBA の初心者ですが、マクロをどのように機能させたいかについて考えがあります。パワーポイントのすべてのスライドをループする必要があります。

1) 矢印の位置を見つけますか? (INSTRコマンドを使用していますか?とCHRコードコマンド。INSTRがpptで機能するかどうか、または適切なコードがここにあるかどうかはわかりません)

2) 前のコード行から返された場所を使用して形状を追加します。私のコードは以下にあり、この形状を仕様に追加しています。

  Dim i As Integer
  Dim shp As Shape
  Dim sld As Slide
  Set sld = Application.ActiveWindow.View.Slide

  Set shp = sld.Shapes.AddShape(36, 10, 10, 5.0399, 8.6399)
  shp.Fill.ForeColor.RGB = RGB(89, 0, 0)
   shp.Fill.BackColor.RGB = RGB(89, 0, 0)
 shp.Line.ForeColor.RGB = RGB(89, 0, 0)

3) すべての文字の矢印を見つけて削除し、形だけが残るようにします。

私は PPT で VBA を使用するのに苦労しており、助けていただければ幸いです。

4

2 に答える 2

3

David が既に行ったことに少し追加すると、テキスト範囲 (テキストのほとんどすべてのチャンク) への参照を取得すると、テキストの境界ボックスを取得し、それを使用して形状を配置できます。ここから始めましょう:

Sub testMe()
    Dim oSh As Shape
    Dim oRng As TextRange

    ' As an example, use the currently selected shape:
    Set oSh = ActiveWindow.Selection.ShapeRange(1)

    With oSh.TextFrame.TextRange
        ' Does it contain the character we're looking for?
        If InStr(.Text, "N") > 0 Then
            ' Get a range representing that character
            Set oRng = .Characters(InStr(.Text, "N"), 1)
            ' And tell us the top
            Debug.Print TopOf(oRng)
            ' And as an exercise for the reader, do companion
            ' BottomOf, LeftOf, WidthOf functions below
            ' then use them here to position/size the shape
            ' atop the existing character
        End If
    End With

End Sub
Function TopOf(oRng As TextRange)
    TopOf = oRng.BoundTop
End Function
于 2013-10-09T23:27:32.703 に答える