0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

パワポマクロ クリップボードの文字列を取得(参照設定しない)

Posted at

パワポでクリップボードの値を取得する方法を記載します。
あまり用途はないけど、たまたま作ったので記録。

通常、クリップボードの値を取得するには参照設定が必要だが、いろいろ制約があったので迂回した。

ロジック

  • クリップボードの値を、新規のShapeに値貼り付け
  • 作成したShapeから文字列を取得
  • 作成したShapeを削除
Public Sub Test() As Slide
    Dim ActiveSlide As Powerpoint.Slide

    Dim sText As String 


    Set ActiveSlide =  ActivePresentation.Slides.FindBySlideID(ActivePresentation.Windows(1).Selection.SlideRange.SlideID)
    On Error GoTo err_
    
    With ActiveSlide.Shapes.PasteSpecial(ppPasteText)
        sText = .TextFrame.TextRange.Text
        .Visible = False
        Call .Delete
    End With

    On Error GoTo 0

    Set ActiveSlide = Nothing

    MsgBox sText 
err_:
End Function

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?