Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Save the contents of the clipboard to a variable

Participant ,
Jan 22, 2025 Jan 22, 2025

Hello

 

I haven't found an easy solution here to work with the clipboard contents by placing it in a variable, to modify it. Using paste() it will be placed in the document. But first I want to format it and delete some of its parts.

 

Regards

TOPICS
Scripting
858
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 22, 2025 Jan 22, 2025

Create TextFrame, paste clipboard, read contents - do what you need. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 22, 2025 Jan 22, 2025

(...and after all delete the TextFrame.)

Only this workaround is possible?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 22, 2025 Jan 22, 2025

It should be possible in official / latest version of JS - but InDesign's version is limited and outdated - and I'm not JS guy, sorry.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 22, 2025 Jan 22, 2025

No problem. Thanks for your answer.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 22, 2025 Jan 22, 2025

You're welcome. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 22, 2025 Jan 22, 2025

Okay, I did that. But I realized this way I couldn't do what I wanted:

 

1. I copy some values ​​from a PDF in Acrobat

2. I select one or more cells in a table in InDesign

3. I paste the (edited) content of my clipboard into the table/cells

 

This would not work in the workflow if I let InDesign create a TextFrame first. Then my selection is lost.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 22, 2025 Jan 22, 2025

Rememmber your selection first.

 

Create a new, invisible document - work there - close - go back to your original document.

 

Selection in InDesign is per Document.

 

There is always more than one way to skin the proverbial cat 😉

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 22, 2025 Jan 22, 2025

What do you mean by “remember”? 😞

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 22, 2025 Jan 22, 2025
quote

What do you mean by “remember”? 😞


By @_AWID_

 

You can save selection to a variable:. 

var myCurSel = app.activeDocument.selection;

 "selection" is a collection like everything else - Stories, Tables, TextFrames, etc.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 22, 2025 Jan 22, 2025

it looks like a good option 🙂

I´ll try as soon as I can. Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jan 22, 2025 Jan 22, 2025

On some platforms, clipboard operations are available from the platform scripting system.

var text = app.doScript("the clipboard as text",ScriptLanguage.APPLESCRIPT_LANGUAGE);

On other platforms, search recommends to use the HTMLFile object.

https://stackoverflow.com/questions/19696308/how-can-i-use-clipboard-in-vbscript

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 22, 2025 Jan 22, 2025

Yes, on Windows, in VB6 it's built-in. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 22, 2025 Jan 22, 2025

I actually work on a Mac.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 23, 2025 Jan 23, 2025
LATEST

Here's how to get the clipboard contents.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines