0

I read in the past that Google does not allow copying values into clipboard but can it at least copy data from clipboard? If there is a way, what would the script look like as I have no clue.

I have a spreadsheet where users copy 2-3 lines of data (Address) from external source (Email or PDF) and then paste that date into multiple cells on the spreadsheet. Users usually have to copy-paste the street1, street2, zip code, state etc. into different cells.

I am trying to create a script where users just need to select address1 cell and then call on the script to get value from clipboard and auto-distribute it to their expected cells. Is this possible?

TheMaster
  • 45,448
  • 6
  • 62
  • 85
Jay
  • 590
  • 6
  • 13
  • 29
  • Related [Automating the new Google Sites via the Clipboard](https://stackoverflow.com/q/54815624/1595451) – Rubén Aug 14 '22 at 18:42
  • 1
    Reading from clipboard is a big security risk. Some browsers [don't allow it at all](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard). That too, from a sandbox iframe is impossible. I don't think Google added the needed security permissions on the iframe. You can request it to Google though. See [tag info page](https://stackoverflow.com/tags/google-apps-script/info) for [Feature request]. Writing to clipboard is not as risky(and is possible). – TheMaster Aug 14 '22 at 18:44
  • Related: https://stackoverflow.com/questions/57681314/add-content-of-showmodaldialog-to-the-clipboard-google-script – TheMaster Aug 14 '22 at 18:54
  • @Cooper Thanks for let me know. No problem. Adding the link here to make it easier to find https://stackoverflow.com/q/11898268/1595451 – Rubén Aug 14 '22 at 19:03
  • I'm not sure how the link helps, I'm working on Google Spreadsheet creating app script to read data from the clipboard and into the cells on a spreadsheet. The link is more on HTML @TheMaster so it's actually reading from clipboard that is a security risk? I thought the other way around, thanks for clarifying – Jay Aug 14 '22 at 19:48
  • 2
    @Jay Think about it.. you copy passwords, sensitive plaintext messages all the time. What if every rogue website got access to it. – TheMaster Aug 14 '22 at 19:52

1 Answers1

1

This is possible with the sidebar on supported browsers, if Google allows clipboard-read permission on the sandboxed iframe. There's a feature request already made:

https://issuetracker.google.com/issues/179172852

Add a +1 to the tracker and comment on how it'll be useful from a business cost point of view, if you want this implemented. Writing to clipboard, however is possible in most browsers without permission.

Related:

Documentation:

TheMaster
  • 45,448
  • 6
  • 62
  • 85