OneNote.Application class

グローバルにアドレス可能な OneNote オブジェクト (ノートブック、アクティブなノートブック、アクティブなセクションなど) すべてを含む最上位のオブジェクトを表します。

Extends

注釈

[ API セット: OneNoteApi 1.1 ]

プロパティ

context

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

notebooks

OneNote アプリケーション インスタンスで開いているノートブックのコレクションを取得します。 OneNote Online では、ノートブックはアプリケーション インスタンスで一度に 1 つだけ開かれます。 読み取り専用です。

メソッド

getActiveNotebook()

存在する場合はアクティブなノートブックを取得します。 アクティブなノートブックがない場合は、ItemNotFound をスローします。

getActiveNotebookOrNull()

存在する場合はアクティブなノートブックを取得します。 アクティブなノートブックがない場合は、null を返します。

getActiveOutline()

存在する場合はアクティブなアウトラインを取得します。アクティブなアウトラインがない場合は、ItemNotFound をスローします。

getActiveOutlineOrNull()

存在する場合はアクティブなアウトラインを取得します。アクティブなアウトラインがない場合は、null を返します。

getActivePage()

存在する場合はアクティブなページを取得します。 アクティブなページがない場合は、ItemNotFound をスローします。

getActivePageOrNull()

存在する場合はアクティブなページを取得します。 アクティブなページがない場合は、null を返します。

getActiveParagraph()

アクティブな Paragraph が存在する場合は取得し、アクティブな段落がない場合は ItemNotFound をスローします。

getActiveParagraphOrNull()

アクティブな Paragraph が存在する場合は取得し、それ以外の場合は null を返します。

getActiveSection()

存在する場合はアクティブなセクションを取得します。 アクティブなセクションがない場合は、ItemNotFound をスローします。

getActiveSectionOrNull()

存在する場合はアクティブなセクションを取得します。 アクティブなセクションがない場合は、null を返します。

getSelectedInkStrokes()

現在選択されているインク ストロークを取得します。

getWindowSize()
insertHtmlAtCurrentPosition(html)
isViewingDeletedNotes()
load(options)

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

load(propertyNames)

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

load(propertyNamesAndPaths)

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

navigateToPage(page)

アプリケーション インスタンスで指定されたページを開きます。

navigateToPageWithClientUrl(url)

指定されたページを取得し、アプリケーション インスタンスで開きます。 失敗しない場合でも、ナビゲーションが実行されない場合があります。 必要に応じて、呼び出し元が返されたページを検証する必要があります。

set(properties, options)

オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。

set(properties)

既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。

toJSON()

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

プロパティの詳細

context

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

context: RequestContext;

プロパティ値

notebooks

OneNote アプリケーション インスタンスで開いているノートブックのコレクションを取得します。 OneNote Online では、ノートブックはアプリケーション インスタンスで一度に 1 つだけ開かれます。 読み取り専用です。

readonly notebooks: OneNote.NotebookCollection;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

メソッドの詳細

getActiveNotebook()

存在する場合はアクティブなノートブックを取得します。 アクティブなノートブックがない場合は、ItemNotFound をスローします。

getActiveNotebook(): OneNote.Notebook;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
        
    // Get the active notebook.
    const notebook = context.application.getActiveNotebook();
            
    // Queue a command to load the notebook.
    // For best performance, request specific properties.
    notebook.load('id,name');
            
    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
                    
    // Show some properties.
    console.log("Notebook name: " + notebook.name);
    console.log("Notebook ID: " + notebook.id);
            
});

getActiveNotebookOrNull()

存在する場合はアクティブなノートブックを取得します。 アクティブなノートブックがない場合は、null を返します。

getActiveNotebookOrNull(): OneNote.Notebook;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

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

    // Get the active notebook.
    const notebook = context.application.getActiveNotebookOrNull();

    // Queue a command to load the notebook.
    // For best performance, request specific properties.
    notebook.load('id,name');

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();

    // Check if active notebook is set.
    if (!notebook.isNullObject) {
        console.log("Notebook name: " + notebook.name);
        console.log("Notebook ID: " + notebook.id);
    }
});

getActiveOutline()

存在する場合はアクティブなアウトラインを取得します。アクティブなアウトラインがない場合は、ItemNotFound をスローします。

getActiveOutline(): OneNote.Outline;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

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

    // get active outline.
    const outline = context.application.getActiveOutline();

    // Queue a command to load the id of the outline.
    outline.load('id');

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();

    // Show some properties.
    console.log("outline id: " + outline.id);
});

getActiveOutlineOrNull()

存在する場合はアクティブなアウトラインを取得します。アクティブなアウトラインがない場合は、null を返します。

getActiveOutlineOrNull(): OneNote.Outline;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

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

    // get active outline.
    const outline = context.application.getActiveOutlineOrNull();

    // Queue a command to load the id of the outline.
    outline.load('id');

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
    if (!outline.isNullObject) {
        console.log("outline id: " + outline.id);
    }
});

getActivePage()

存在する場合はアクティブなページを取得します。 アクティブなページがない場合は、ItemNotFound をスローします。

getActivePage(): OneNote.Page;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
        
    // Get the active page.
    const page = context.application.getActivePage();
            
    // Queue a command to load the page.
    // For best performance, request specific properties.
    page.load('id,title');
            
    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
                    
    // Show some properties.
    console.log("Page title: " + page.title);
    console.log("Page ID: " + page.id);
});

getActivePageOrNull()

存在する場合はアクティブなページを取得します。 アクティブなページがない場合は、null を返します。

getActivePageOrNull(): OneNote.Page;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

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

    // Get the active page.
    const page = context.application.getActivePageOrNull();

    // Queue a command to load the page.
    // For best performance, request specific properties.
    page.load('id,title');

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
            
    if (!page.isNullObject) {
        // Show some properties.
        console.log("Page title: " + page.title);
        console.log("Page ID: " + page.id);
    }
});

getActiveParagraph()

アクティブな Paragraph が存在する場合は取得し、アクティブな段落がない場合は ItemNotFound をスローします。

getActiveParagraph(): OneNote.Paragraph;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

getActiveParagraphOrNull()

アクティブな Paragraph が存在する場合は取得し、それ以外の場合は null を返します。

getActiveParagraphOrNull(): OneNote.Paragraph;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

getActiveSection()

存在する場合はアクティブなセクションを取得します。 アクティブなセクションがない場合は、ItemNotFound をスローします。

getActiveSection(): OneNote.Section;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

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

getActiveSectionOrNull()

存在する場合はアクティブなセクションを取得します。 アクティブなセクションがない場合は、null を返します。

getActiveSectionOrNull(): OneNote.Section;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

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

    // Get the active section.
    const section = context.application.getActiveSectionOrNull();

    // Queue a command to load the section.
    // For best performance, request specific properties.
    section.load('id,name');

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
    if (!section.isNullObject) {
        // Show some properties.
        console.log("Section name: " + section.name);
        console.log("Section ID: " + section.id);
    }
});

getSelectedInkStrokes()

現在選択されているインク ストロークを取得します。

getSelectedInkStrokes(): OneNote.InkStrokeCollection;

戻り値

注釈

[ API セット: OneNoteApi 1.9 ]

getWindowSize()

getWindowSize(): OfficeExtension.ClientResult<number[]>;

戻り値

insertHtmlAtCurrentPosition(html)

insertHtmlAtCurrentPosition(html: string): void;

パラメーター

html

string

戻り値

void

isViewingDeletedNotes()

isViewingDeletedNotes(): OfficeExtension.ClientResult<boolean>;

戻り値

load(options)

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

load(options?: OneNote.Interfaces.ApplicationLoadOptions): OneNote.Application;

パラメーター

options
OneNote.Interfaces.ApplicationLoadOptions

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

戻り値

load(propertyNames)

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

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

パラメーター

propertyNames

string | string[]

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

戻り値

load(propertyNamesAndPaths)

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

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

パラメーター

propertyNamesAndPaths

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

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

戻り値

navigateToPage(page)

アプリケーション インスタンスで指定されたページを開きます。

navigateToPage(page: OneNote.Page): void;

パラメーター

page
OneNote.Page

開くページです。

戻り値

void

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
        
    // Get the pages in the current section.
    const pages = context.application.getActiveSection().pages;
            
    // Queue a command to load the pages.
    // For best performance, request specific properties.
    pages.load('id');
            
    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync()
                    
    // This example loads the first page in the section.
    const page = pages.items[0];
                
    // Open the page in the application.
    context.application.navigateToPage(page);
            
    // Run the queued command.
    await context.sync();
});

navigateToPageWithClientUrl(url)

指定されたページを取得し、アプリケーション インスタンスで開きます。 失敗しない場合でも、ナビゲーションが実行されない場合があります。 必要に応じて、呼び出し元が返されたページを検証する必要があります。

navigateToPageWithClientUrl(url: string): OneNote.Page;

パラメーター

url

string

開くページのクライアント URL です。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

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

    // Get the pages in the current section.
    const pages = context.application.getActiveSection().pages;

    // Queue a command to load the pages.
    // For best performance, request specific properties.
    pages.load('clientUrl');

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync()

    // This example loads the first page in the section.
    const page = pages.items[0];

    // Open the page in the application.
    context.application.navigateToPageWithClientUrl(page.clientUrl);

    // Run the queued command.
    await context.sync();
});

set(properties, options)

オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。

set(properties: Interfaces.ApplicationUpdateData, options?: OfficeExtension.UpdateOptions): void;

パラメーター

properties
OneNote.Interfaces.ApplicationUpdateData

メソッドが呼び出されるオブジェクトのプロパティに等形的に構造化されたプロパティを持つ JavaScript オブジェクト。

options
OfficeExtension.UpdateOptions

properties オブジェクトが読み取り専用プロパティを設定しようとした場合にエラーを抑制するオプションを提供します。

戻り値

void

set(properties)

既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。

set(properties: OneNote.Application): void;

パラメーター

properties
OneNote.Application

戻り値

void

toJSON()

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

toJSON(): OneNote.Interfaces.ApplicationData;

戻り値