PowerPoint.Hyperlink class
1 つのハイパーリンクを表します。
- Extends
注釈
使用元
- PowerPoint.HyperlinkCollection: add, getItemAt, items
- PowerPoint.HyperlinkScopedCollection: getItemAt, items
- PowerPoint.Shape: setHyperlink
- PowerPoint.TextRange: setHyperlink
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/hyperlinks/manage-hyperlinks.yaml
// Gets the hyperlinks found in the first selected slide.
await PowerPoint.run(async (context) => {
const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
const hyperlinks: PowerPoint.HyperlinkCollection = slide.hyperlinks.load("address,screenTip");
const hyperlinksCount = hyperlinks.getCount();
await context.sync();
console.log(
`${hyperlinksCount.value} hyperlinks found in first selected slide${hyperlinksCount.value === 0 ? "." : ":"}`,
);
for (let link of hyperlinks.items) {
console.log(`Address: "${link.address}" (screen tip: "${link.screenTip}").`);
}
});
プロパティ
| address | ハイパーリンクのアドレス (URL、ファイル名、ファイル パス、または |
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| screen |
ハイパーリンクにカーソルを合わせたときに表示される文字列を指定します。 |
| type | ハイパーリンクが適用されているオブジェクトの型を返します。 詳細については、「 PowerPoint.HyperlinkType 」を参照してください。 |
メソッド
| delete() | ハイパーリンクを削除します。 |
| get |
ハイパーリンクが適用されている PowerPoint.Shape オブジェクトを返します。 ハイパーリンクの種類が |
| get |
ハイパーリンクが適用されている PowerPoint.TextRange オブジェクトを返します。 ハイパーリンクが |
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| toJSON() | API オブジェクトが |
プロパティの詳細
address
ハイパーリンクのアドレス (URL、ファイル名、ファイル パス、または mailto URI スキームを持つ電子メール アドレス) を指定します。
address: string;
プロパティ値
string
注釈
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
screenTip
type
ハイパーリンクが適用されているオブジェクトの型を返します。 詳細については、「 PowerPoint.HyperlinkType 」を参照してください。
readonly type: PowerPoint.HyperlinkType | "TextRange" | "Shape";
プロパティ値
PowerPoint.HyperlinkType | "TextRange" | "Shape"
注釈
メソッドの詳細
delete()
ハイパーリンクを削除します。
delete(): void;
返品
void
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/hyperlinks/manage-hyperlinks.yaml
// Deletes the first hyperlink found in the selected text on the current slide.
await PowerPoint.run(async (context) => {
const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange().load("text");
let hyperlink: PowerPoint.Hyperlink = textRange.hyperlinks.getItemAt(0).load("address,screenTip");
try {
await context.sync();
} catch {
console.warn(
"Confirm that you have at least one slide and you've selected a contiguous range of text containing at least one hyperlink on the active slide.",
);
return;
}
console.log(
`About to delete first link "${hyperlink.address}" (screen tip: "${hyperlink.screenTip}") found in the selected text "${textRange.text}".`,
);
hyperlink.delete();
console.log(`Deleted first link found in the selected text "${textRange.text}".`);
});
getLinkedShapeOrNullObject()
ハイパーリンクが適用されている PowerPoint.Shape オブジェクトを返します。 ハイパーリンクの種類が shape でない場合、または PowerPoint.Shape を現在サポートしていないドメイン内にある場合は、 isNullObject プロパティが true に設定されたオブジェクトをこのメソッドで返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。
getLinkedShapeOrNullObject(): PowerPoint.Shape;
返品
注釈
getLinkedTextRangeOrNullObject()
ハイパーリンクが適用されている PowerPoint.TextRange オブジェクトを返します。 ハイパーリンクが textRange 型ではない場合、または PowerPoint.TextRange を現在サポートしていないドメイン内にある場合、このメソッドは isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。
getLinkedTextRangeOrNullObject(): PowerPoint.TextRange;
返品
注釈
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: PowerPoint.Interfaces.HyperlinkLoadOptions): PowerPoint.Hyperlink;
パラメーター
読み込むオブジェクトのプロパティのオプションを指定します。
返品
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNames?: string | string[]): PowerPoint.Hyperlink;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切りの文字列または文字列の配列。
返品
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): PowerPoint.Hyperlink;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列であり、 propertyNamesAndPaths.expand は読み込むナビゲーションのプロパティを指定するコンマ区切りの文字列です。
返品
toJSON()
API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の PowerPoint.Hyperlink オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( PowerPoint.Interfaces.HyperlinkData と型指定) を返します。
toJSON(): PowerPoint.Interfaces.HyperlinkData;