ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   GetFromClipboard help needed please (https://www.excelbanter.com/excel-programming/402807-getfromclipboard-help-needed-please.html)

LuisE

GetFromClipboard help needed please
 
I want to copy the content of a TextBox and paste it to Notepad.
I have the first piece working, I'm opening Notepad but I can't paste it. I
don't want to use SendKeys (Ctrl+V).

This is what I have


Private Sub CommandButton4_Click()

Dim MsgToNotepad
Dim DataObj As New MSForms.DataObject
Dim WshShell

Me.TxtMessage.SelStart = 0
Me.TxtMessage.SelLength = Me.TxtMessage.TextLength
Set MsgToNotepad = Me.TxtMessage 'selects multiline textbox contents
MsgToNotepad.Copy 'copies it to Clipboard

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "Notepad" 'runs Notepad

Dim IntoNotepad As String 'gets it from clipboard and pasts it into Notepad
MsgToNotepad.GetFromClipboard
IntoNotepad = MsgToNotepad.GetText

End Sub



THANKS IS ADVANCE



All times are GMT +1. The time now is 11:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com