copy from textbox/label/variable to clipboard

amigos

Active Member
Joined
Sep 23, 2003
Messages
407
hi guys

I have a spreadsheet with list of our applications and passwords to VBA projects - but as I was tired of opening this every time I wanted to edit VBA - I created a macro which opens it and shows all projects and passwords on the list box. Now I want to be able to copy the password from List Box to Clipboard so I can hit alt+F11 and paste password to unprotect the project...

Q: how do I copy variable to Clipboard???

thanks in advance
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Don't know about the Alt+F11 paste part. I messed around with a bit of code which I hope will get you started. It seemed like the clipboard had to reference the listbox value via a spreadsheet range to work. I'll post this and maybe it will get the ball rolling. Good luck amigos! Dave
Code:
Private Sub CommandButton1_Click()
Dim Astring As String, cnt As Integer
Dim MyData As DataObject
'copies A1 to clipboard
'gets from clipboard and put in B1
If ListBox1.ListCount < 5 Then
ListBox1.Clear
For cnt = 1 To 5
ListBox1.AddItem cnt
Next cnt
End If
'code above used only for testing
[sheet1!a1] = ListBox1.Value
[sheet1!a1].Copy
Set MyData = New DataObject
    MyData.GetFromClipboard
    Astring = MyData.GetText(1)
[sheet1!b1] = Astring
Application.CutCopyMode = False
Set MyData = Nothing
End Sub
 
Upvote 0
It may or may not work in your case, but to copy the text, you'd use Control-C, and to paste it, Control-V. Hope that helps!

EDIT: Sometimes, but not all the time, you can right-click and select copy and paste from the menu that pops up, after you select text.
 
Upvote 0

Forum statistics

Threads
1,203,073
Messages
6,053,381
Members
444,660
Latest member
Mingalsbe

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top