Using IE to seed the clipboard

Weaver

Well-known Member
Joined
Sep 10, 2008
Messages
5,197
I had a bit of vbs code that seeded certain strings into the clipboard

Code:
    With CreateObject("internetexplorer.application")
        .navigate ("about:blank")
        .document.parentwindow.clipboarddata.SetData "text", a
        .Quit
    End With
I need to use this in excel but as it currently stands, it issues an alert "Do you want this webpage to access your clipboard". Can I override this? Or is there a better way to achieve the same result?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I tried that, but I think maybe the IE equivalent is required inside the with..end with
 
Upvote 0
Are you just trying to put text in the clipboard?
 
Upvote 0
Yes, that's about it. It's for a system variable (the full path name) so that users can hit shift-ctrl-F then paste into other apps (mostly lotus notes). I imagine I could just write the value to a cell and copy it from there, but I was trying to avoid that.
 
Upvote 0
Try this:
Code:
Public Sub PutInClipBoard(strText as string)
   Dim objData As Object
   Set objData = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
   
   With objData
      .SetText strText
      .PutInClipboard
   End With

End Sub
 
Upvote 0
That did the trick, thanks.

What's the syntax/logic behind that getobject() call, if you don't mind me asking?

Would this work in VBS also? It'd save messing around with internet explorer.

Cheers,
 
Upvote 0

Forum statistics

Threads
1,224,538
Messages
6,179,412
Members
452,912
Latest member
alicemil

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