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

How to convert text selection into Hyperlink?

Community Beginner ,
Mar 22, 2019 Mar 22, 2019

Mytext1, mytext2, mytext3.

I'd like to select mytext2 and convert it to hyperlink (like as by context menu: Hyperlink - New hyperlink from URL.)

Is it possible?

Thanks.

TOPICS
Scripting
2.3K
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

correct answers 1 Correct answer

Community Expert , Mar 22, 2019 Mar 22, 2019

Something like the following should work, run the code with a text selection and it should create the hyperlink on it. Change the app.selection[0] to the object of the text that you might have in your actual code

var source = app.documents[0].hyperlinkTextSources.add(app.selection[0])

var dest = app.documents[0].hyperlinkURLDestinations.add("http://"+ app.selection[0].contents)

app.documents[0].hyperlinks.add(source,dest, {name:app.selection[0].contents})

-Manan

Translate
Community Expert ,
Mar 22, 2019 Mar 22, 2019

Something like the following should work, run the code with a text selection and it should create the hyperlink on it. Change the app.selection[0] to the object of the text that you might have in your actual code

var source = app.documents[0].hyperlinkTextSources.add(app.selection[0])

var dest = app.documents[0].hyperlinkURLDestinations.add("http://"+ app.selection[0].contents)

app.documents[0].hyperlinks.add(source,dest, {name:app.selection[0].contents})

-Manan

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
Community Beginner ,
Mar 22, 2019 Mar 22, 2019
LATEST

Many 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