View Full Version : Paste into a comment box directly from clipboard?
londresw
01-12-2009, 02:38 AM
Hi,
Is it possible to paste into a comment box or string variable directly?
I'd like to paste a bit of data in the following format directly from the clipboard.(inc. chr) into a) a variable and b) a comment box
Mobile No: 07766555512
IMSI: 234159007505465
Date: 23/12/08
SDR: 101.732
Country: Morocco
Hi,
Is it possible to paste into a comment box or string variable directly?
I'd like to paste a bit of data in the following format directly from the clipboard.(inc. chr) into a) a variable and b) a comment box
Mobile No: 07766555512
IMSI: 234159007505465
Date: 23/12/08
SDR: 101.732
Country: Morocco
Greetings londresw,
Well... here's my first chance to be wrong today, but I don't think pasting in a comment is going to be a happening thing.
You can however, add comments, or modify existing comments. I have had some luck in carefully seeing how many characters are/should be present, and tacking stuff onto the end.
Presuming you want to add or modify the comment from either a cell, textbox, userform textbox (or some other control), I would be thinking of using the string from the textbox or cell, and then assigning this to the text of the comment.
Here's an awfully simple example of creating and modifying a comment.
Sub Comment_ADD()
On Error Resume Next
Sheet1.Range("A2").Comment.Delete
On Error GoTo 0
With Sheet1.Range("A2").AddComment
.Text "Line One" & Chr(10) & _
"Line Two" & Chr(10) & _
"Line Three"
.Visible = False
End With
Sheet1.Range("A2").Comment. _
Text Text:=Chr(10) & "Added Line", Start:=29, Overwrite:=False
End Sub
Hope this helps,
Mark
mikerickson
01-12-2009, 07:07 AM
Dim myClip As New DataObject
Dim myString As String
myClip.GetFromClipboard
myString = myClip.GetText
Sheet1.Range("A1").AddComment myStringI didn't test very hard. It might be interesting to see what happens if an image is in the clipboard.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.