0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Office scriptのsetHyperlinkでドキュメント内のリンクが貼れない

Posted at

はじめに

タイトルの通りなのですが、setHyperlinkでドキュメント内のリンクが貼れないケースがあり、原因と解決方法がわかったので記事にします。

リンクが貼れなかったのは、一覧 (3)というシート名でした。

原因

シート名にスペースや特殊文字が含まれている場合、正しく認識されないみたいです。

解決策

シングルクオーテーションで囲みます。

const targetSheetName = "一覧 (3)";
sheet.getRange("A1").setHyperlink({
    documentReference: `'${targetSheetName}'!A1`,
    textToDisplay: targetSheetName,
    screenTip: targetSheetName,
});
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?