OneNote.Section class

OneNote セクションを表します。 セクションには、ページを含めることができます。

Extends

注釈

[ API セット: OneNoteApi 1.1 ]

プロパティ

clientUrl

セクションのクライアント url です。 読み取りのみ

context

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

id

セクションの ID を取得します。 読み取り専用です。

isEncrypted

True の場合、このセクションはパスワードで暗号化されます。 読み取りのみ

isLocked

このセクションがロックされている場合は True。 読み取りのみ

name

セクションの名前を取得します。 読み取り専用です。

notebook

セクションを含むノートブックを取得します。 読み取り専用です。

pages

セクション内のページのコレクションです。 読み取りのみ

parentSectionGroup

セクションを含むセクション グループを取得します。 セクションがノートブックの直接の子である場合は ItemNotFound をスローします。 読み取り専用です。

parentSectionGroupOrNull

セクションを含むセクション グループを取得します。 セクションがノートブックの直接の子である場合は null を返します。 読み取り専用です。

webUrl

ページの Web URL。 読み取りのみ

メソッド

addPage(title)

セクションの末尾に新しいページを追加します。

copyToNotebook(destinationNotebook)

指定したノートブックに、このセクションをコピーします。

copyToSectionGroup(destinationSectionGroup)

指定したセクション グループに、このセクションをコピーします。

getRestApiId()

REST API ID を取得します。

insertSectionAsSibling(location, title)

現在のセクションの前か後に、新しいセクションを挿入します。

insertSectionAsSibling(locationString, title)

現在のセクションの前か後に、新しいセクションを挿入します。

load(options)

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

load(propertyNames)

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

load(propertyNamesAndPaths)

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

toJSON()

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

track()

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

untrack()

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

プロパティの詳細

clientUrl

セクションのクライアント url です。 読み取りのみ

readonly clientUrl: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

context

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

context: RequestContext;

プロパティ値

id

セクションの ID を取得します。 読み取り専用です。

readonly id: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

isEncrypted

True の場合、このセクションはパスワードで暗号化されます。 読み取りのみ

readonly isEncrypted: boolean;

プロパティ値

boolean

注釈

[ API セット: OneNoteApi 1.2 ]

isLocked

このセクションがロックされている場合は True。 読み取りのみ

readonly isLocked: boolean;

プロパティ値

boolean

注釈

[ API セット: OneNoteApi 1.2 ]

name

セクションの名前を取得します。 読み取り専用です。

readonly name: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

notebook

セクションを含むノートブックを取得します。 読み取り専用です。

readonly notebook: OneNote.Notebook;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

pages

セクション内のページのコレクションです。 読み取りのみ

readonly pages: OneNote.PageCollection;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

parentSectionGroup

セクションを含むセクション グループを取得します。 セクションがノートブックの直接の子である場合は ItemNotFound をスローします。 読み取り専用です。

readonly parentSectionGroup: OneNote.SectionGroup;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

parentSectionGroupOrNull

セクションを含むセクション グループを取得します。 セクションがノートブックの直接の子である場合は null を返します。 読み取り専用です。

readonly parentSectionGroupOrNull: OneNote.SectionGroup;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

webUrl

ページの Web URL。 読み取りのみ

readonly webUrl: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

メソッドの詳細

addPage(title)

セクションの末尾に新しいページを追加します。

addPage(title: string): OneNote.Page;

パラメーター

title

string

新しいページのタイトルです。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
            
    // Queue a command to add a page to the current section.
    const page = context.application.getActiveSection().addPage("Wish list");
            
    // Queue a command to load the id and title of the new page.
    // This example loads the new page so it can read its properties later.
    page.load('id,title');
            
    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
             
    // Display the properties.
    console.log("Page name: " + page.title);
    console.log("Page ID: " + page.id);
});

copyToNotebook(destinationNotebook)

指定したノートブックに、このセクションをコピーします。

copyToNotebook(destinationNotebook: OneNote.Notebook): OneNote.Section;

パラメーター

destinationNotebook
OneNote.Notebook

このセクションのコピー先のノートブック。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
    const app = context.application;
    
    // Gets the active Notebook.
    const notebook = app.getActiveNotebook();
    
    // Gets the active Section.
    const section = app.getActiveSection();
    
    let newSection;
    
    await context.sync();

    newSection = section.copyToNotebook(notebook);
    newSection.load('id');
    await context.sync();
    
    console.log(newSection.id);
});

copyToSectionGroup(destinationSectionGroup)

指定したセクション グループに、このセクションをコピーします。

copyToSectionGroup(destinationSectionGroup: OneNote.SectionGroup): OneNote.Section;

パラメーター

destinationSectionGroup
OneNote.SectionGroup

このセクションのコピー先のセクション グループ。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
    const app = context.application;
    
    // Gets the active Notebook.
    const notebook = app.getActiveNotebook();
    
    // Gets the active Section.
    const section = app.getActiveSection();
    
    let newSection;
    
    await context.sync();

    const firstSectionGroup = notebook.sectionGroups.items[0];
    newSection = section.copyToSectionGroup(firstSectionGroup);
    newSection.load('id');
    await context.sync();
    
    console.log(newSection.id);
});

getRestApiId()

REST API ID を取得します。

getRestApiId(): OfficeExtension.ClientResult<string>;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
    // Get the current section.
    const section = context.application.getActiveSection();
    const restApiId = section.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
});

insertSectionAsSibling(location, title)

現在のセクションの前か後に、新しいセクションを挿入します。

insertSectionAsSibling(location: OneNote.InsertLocation, title: string): OneNote.Section;

パラメーター

location
OneNote.InsertLocation

現在のセクションを基準にした新しいセクションの場所です。

title

string

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

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

insertSectionAsSibling(locationString, title)

現在のセクションの前か後に、新しいセクションを挿入します。

insertSectionAsSibling(locationString: "Before" | "After", title: string): OneNote.Section;

パラメーター

locationString

"Before" | "After"

現在のセクションを基準にした新しいセクションの場所です。

title

string

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

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
            
    // Queue a command to insert a section after the current section.
    const section = context.application.getActiveSection().insertSectionAsSibling("After", "New section");
            
    // Queue a command to load the id and name of the new section.
    // This example loads the new section so it can read its properties later.
    section.load('id,name');
            
    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
             
    // Display the properties.
    console.log("Section name: " + section.name);
    console.log("Section ID: " + section.id);
});

load(options)

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

load(options?: OneNote.Interfaces.SectionLoadOptions): OneNote.Section;

パラメーター

options
OneNote.Interfaces.SectionLoadOptions

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

戻り値

load(propertyNames)

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

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

パラメーター

propertyNames

string | string[]

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

戻り値

await OneNote.run(async (context) => {
        
    // Get the current section.
    const section = context.application.getActiveSection();
            
    // Queue a command to load the section.
    // For best performance, request specific properties.
    section.load("id");
            
    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
    console.log("Section ID: " + section.id);
});

load(propertyNamesAndPaths)

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

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

パラメーター

propertyNamesAndPaths

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

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

戻り値

toJSON()

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

toJSON(): OneNote.Interfaces.SectionData;

戻り値

track()

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

track(): OneNote.Section;

戻り値

untrack()

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

untrack(): OneNote.Section;

戻り値