OneNote.Notebook class

OneNote ノートブックを表します。 ノートブックには、セクション グループとセクションが含まれます。

Extends

注釈

[ API セット: OneNoteApi 1.1 ]

プロパティ

baseUrl

このノートブックが配置されているサイトの URL。 読み取りのみ

clientUrl

ノートブックのクライアント URL。 読み取りのみ

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

id

ノートブックの ID を取得します。 読み取り専用です。

isVirtual

True を指定すると、ノートブックがユーザーによって作成されない場合 (つまり、"誤ったセクション")。 読み取りのみ

name

ノートブックの名前を取得します。 読み取り専用です。

sectionGroups

ノートブック内のセクション グループ。 読み取りのみ

sections

ノートブックのセクション。 読み取りのみ

メソッド

addSection(name)

ノートブックの末尾に新しいセクションを追加します。

addSectionGroup(name)

ノートブックの末尾に新しいセクション グループを追加します。

getRestApiId()

REST API ID を取得します。

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

toJSON()

API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドを JSON.stringify()オーバーライドします。 (JSON.stringifyさらに、渡される オブジェクトの メソッドを呼び出 toJSON します)。元の OneNote.Notebook オブジェクトは API オブジェクトですが、メソッドは、元の toJSON オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として OneNote.Interfaces.NotebookData型指定) を返します。

track()

ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは の短縮形です context.trackedObjects.add(thisObject)。 このオブジェクトを呼び出しで .sync 使用し、".run" バッチのシーケンシャル実行の外部で使用していて、プロパティを設定するとき、またはオブジェクトのメソッドを呼び出すときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。

untrack()

前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは の context.trackedObjects.remove(thisObject)短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に を呼び出す context.sync() 必要があります。

プロパティの詳細

baseUrl

このノートブックが配置されているサイトの URL。 読み取りのみ

readonly baseUrl: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

clientUrl

ノートブックのクライアント URL。 読み取りのみ

readonly clientUrl: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

context: RequestContext;

プロパティ値

id

ノートブックの ID を取得します。 読み取り専用です。

readonly id: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

isVirtual

True を指定すると、ノートブックがユーザーによって作成されない場合 (つまり、"誤ったセクション")。 読み取りのみ

readonly isVirtual: boolean;

プロパティ値

boolean

注釈

[ API セット: OneNoteApi 1.2 ]

name

ノートブックの名前を取得します。 読み取り専用です。

readonly name: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

sectionGroups

ノートブック内のセクション グループ。 読み取りのみ

readonly sectionGroups: OneNote.SectionGroupCollection;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

sections

ノートブックのセクション。 読み取りのみ

readonly sections: OneNote.SectionCollection;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

メソッドの詳細

addSection(name)

ノートブックの末尾に新しいセクションを追加します。

addSection(name: string): OneNote.Section;

パラメーター

name

string

新しいセクションの名前を指定します。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {

    // Gets the active notebook.
    const notebook = context.application.getActiveNotebook();

    // Queue a command to add a new section.
    const section = notebook.addSection("Sample section");
    
    // Queue a command to load the new section. This example reads the name property later.
    section.load("name");

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
    console.log("New section name is " + section.name);
});

addSectionGroup(name)

ノートブックの末尾に新しいセクション グループを追加します。

addSectionGroup(name: string): OneNote.SectionGroup;

パラメーター

name

string

新しいセクションの名前を指定します。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {

    // Gets the active notebook.
    const notebook = context.application.getActiveNotebook();

    // Queue a command to add a new section group.
    const sectionGroup = notebook.addSectionGroup("Sample section group");

    // Queue a command to load the new section group.
    sectionGroup.load();

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
    console.log("New section group name is " + sectionGroup.name);
});

getRestApiId()

REST API ID を取得します。

getRestApiId(): OfficeExtension.ClientResult<string>;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
    // Get the current notebook.
    const notebook = context.application.getActiveNotebook();
    const restApiId = notebook.getRestApiId();

    await context.sync();
    console.log("The REST API ID is " + restApiId.value);
    // Note that the REST API ID isn't all you need to interact with the OneNote REST API.
    // This is only required for SharePoint notebooks. baseUrl will be null for OneDrive notebooks.
    // For SharePoint notebooks, the notebook baseUrl should be used to talk to the OneNote REST API
    // according to the OneNote Development Blog.
    // https://learn.microsoft.com/archive/blogs/onenotedev/and-sharepoint-makes-three
});

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(options?: OneNote.Interfaces.NotebookLoadOptions): OneNote.Notebook;

パラメーター

options
OneNote.Interfaces.NotebookLoadOptions

読み込むオブジェクトのプロパティのオプションを提供します。

戻り値

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames?: string | string[]): OneNote.Notebook;

パラメーター

propertyNames

string | string[]

読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。

戻り値

await OneNote.run(async (context) => {
        
    // Get the current notebook.
    const notebook = context.application.getActiveNotebook();
            
    // Queue a command to load the notebook.
    // For best performance, request specific properties.
    notebook.load('baseUrl');
            
    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
    console.log("Base url: " + notebook.baseUrl);
    // This is only required for SharePoint notebooks, and will be null for OneDrive notebooks.
    // This baseUrl should be used to talk to OneNote REST APIs according to the OneNote Development Blog.
    // https://learn.microsoft.com/archive/blogs/onenotedev/and-sharepoint-makes-three
});

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): OneNote.Notebook;

パラメーター

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select は、読み込むプロパティを指定するコンマ区切り文字列で propertyNamesAndPaths.expand 、読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。

戻り値

toJSON()

API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドを JSON.stringify()オーバーライドします。 (JSON.stringifyさらに、渡される オブジェクトの メソッドを呼び出 toJSON します)。元の OneNote.Notebook オブジェクトは API オブジェクトですが、メソッドは、元の toJSON オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として OneNote.Interfaces.NotebookData型指定) を返します。

toJSON(): OneNote.Interfaces.NotebookData;

戻り値

track()

ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは の短縮形です context.trackedObjects.add(thisObject)。 このオブジェクトを呼び出しで .sync 使用し、".run" バッチのシーケンシャル実行の外部で使用していて、プロパティを設定するとき、またはオブジェクトのメソッドを呼び出すときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。

track(): OneNote.Notebook;

戻り値

untrack()

前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは の context.trackedObjects.remove(thisObject)短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に を呼び出す context.sync() 必要があります。

untrack(): OneNote.Notebook;

戻り値