teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

コード追加

2020/12/10 04:50

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -46,4 +46,27 @@
46
46
  ```
47
47
 
48
48
  参考リンク
49
- [クリップボードとデータのやりとりをする:Excel VBA|即効テクニック|Excel VBAを学ぶならmoug](https://www.moug.net/tech/exvba/0150091.html)
49
+ [クリップボードとデータのやりとりをする:Excel VBA|即効テクニック|Excel VBAを学ぶならmoug](https://www.moug.net/tech/exvba/0150091.html)
50
+
51
+ 別案追記
52
+ ---
53
+ DataObjectを使わない方法
54
+
55
+ ```vba
56
+ Sub CopyToClipBoard()
57
+ SetCB ActiveCell.Text
58
+ End Sub
59
+
60
+ Private Sub SetCB(ByVal str As String)
61
+ 'クリップボードに文字列を格納
62
+ With CreateObject("Forms.TextBox.1")
63
+ .MultiLine = True
64
+ .Text = str
65
+ .SelStart = 0
66
+ .SelLength = .TextLength
67
+ .Copy
68
+ End With
69
+ End Sub
70
+ ```
71
+
72
+ [VBA \- VBAでクリップボードへのコピー|teratail](https://teratail.com/questions/203287)