Word.SearchOptions class

検索操作に含めるオプションを指定します。 Word JavaScript API で検索オプションを使用する方法の詳細については、「検索オプションを使用してWord アドイン内のテキストを検索する」を参照してください。

Extends

注釈

[ API セット: WordApi 1.1 ]

プロパティ

context

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

ignorePunct

単語間のすべての句読点文字を無視するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [句読点を無視する] チェック ボックスに相当します。

ignoreSpace

単語間のすべての空白を無視するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [空白文字チェック無視する] ボックスに対応します。

matchCase

大文字と小文字を区別する検索を実行するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [大文字と小文字チェック一致] ボックスに対応します。

matchPrefix

検索文字列で始まる単語と一致するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [接頭辞に一致する] チェック ボックスに相当します。

matchSuffix

検索文字列で終わる単語と一致するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [接尾辞に一致する] に相当します。

matchWholeWord

大きな単語の一部であるテキストではなく、単語全体のみを検索するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [完全に一致する単語だけを検索する] チェック ボックスに相当します。

matchWildcards

特殊な検索演算子を使用して検索を実行するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [ワイルドカードを使用する] チェック ボックスに相当します。

メソッド

load(options)

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

load(propertyNames)

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

load(propertyNamesAndPaths)

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

newObject(context)

Wordの新しいインスタンスを作成します。SearchOptions オブジェクト

set(properties, options)

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

set(properties)

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

toJSON()

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

プロパティの詳細

context

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

context: RequestContext;

プロパティ値

ignorePunct

単語間のすべての句読点文字を無視するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [句読点を無視する] チェック ボックスに相当します。

ignorePunct: boolean;

プロパティ値

boolean

注釈

[ API セット: WordApi 1.1 ]

ignoreSpace

単語間のすべての空白を無視するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [空白文字チェック無視する] ボックスに対応します。

ignoreSpace: boolean;

プロパティ値

boolean

注釈

[ API セット: WordApi 1.1 ]

matchCase

大文字と小文字を区別する検索を実行するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [大文字と小文字チェック一致] ボックスに対応します。

matchCase: boolean;

プロパティ値

boolean

注釈

[ API セット: WordApi 1.1 ]

matchPrefix

検索文字列で始まる単語と一致するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [接頭辞に一致する] チェック ボックスに相当します。

matchPrefix: boolean;

プロパティ値

boolean

注釈

[ API セット: WordApi 1.1 ]

matchSuffix

検索文字列で終わる単語と一致するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [接尾辞に一致する] に相当します。

matchSuffix: boolean;

プロパティ値

boolean

注釈

[ API セット: WordApi 1.1 ]

matchWholeWord

大きな単語の一部であるテキストではなく、単語全体のみを検索するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [完全に一致する単語だけを検索する] チェック ボックスに相当します。

matchWholeWord: boolean;

プロパティ値

boolean

注釈

[ API セット: WordApi 1.1 ]

matchWildcards

特殊な検索演算子を使用して検索を実行するかどうかを示す値を指定します。 [検索と置換] ダイアログ ボックスの [ワイルドカードを使用する] チェック ボックスに相当します。

matchWildcards: boolean;

プロパティ値

boolean

注釈

[ API セット: WordApi 1.1 ]

メソッドの詳細

load(options)

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

load(options?: Word.Interfaces.SearchOptionsLoadOptions): Word.SearchOptions;

パラメーター

options
Word.Interfaces.SearchOptionsLoadOptions

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

戻り値

// Ignore punctuation search
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
    
    // Queue a command to search the document and ignore punctuation.
    const searchResults = context.document.body.search('video you', {ignorePunct: true});

    // Queue a command to load the search results and get the font property values.
    searchResults.load('font');
    
    // Synchronize the document state by executing the queued commands, 
    // and return a promise to indicate task completion.
    await context.sync();
    console.log('Found count: ' + searchResults.items.length);

    // Queue a set of commands to change the font for each found item.
    for (let i = 0; i < searchResults.items.length; i++) {
        searchResults.items[i].font.color = 'purple';
        searchResults.items[i].font.highlightColor = '#FFFF00'; //Yellow
        searchResults.items[i].font.bold = true;
    }
    
    // Synchronize the document state by executing the queued commands, 
    // and return a promise to indicate task completion.
    await context.sync();
});  
// Search based on a prefix
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
    
    // Queue a command to search the document based on a prefix.
    const searchResults = context.document.body.search('vid', {matchPrefix: true});

    // Queue a command to load the search results and get the font property values.
    searchResults.load('font');
    
    // Synchronize the document state by executing the queued commands, 
    // and return a promise to indicate task completion.
    await context.sync();

    // Queue a set of commands to change the font for each found item.
    for (let i = 0; i < searchResults.items.length; i++) {
        searchResults.items[i].font.color = 'purple';
        searchResults.items[i].font.highlightColor = '#FFFF00'; //Yellow
        searchResults.items[i].font.bold = true;
    }
    
    // Synchronize the document state by executing the queued commands, 
    // and return a promise to indicate task completion.
    await context.sync();
}); 
// Search based on a suffix
// Run a batch operation against the Word object model.
await Word.run(async (context) => {

    // Queue a command to search the document for any string of characters after 'ly'.
    const searchResults = context.document.body.search('ly', {matchSuffix: true});

    // Queue a command to load the search results and get the font property values.
    searchResults.load('font');
    
    // Synchronize the document state by executing the queued commands, 
    // and return a promise to indicate task completion.
    await context.sync();
    console.log('Found count: ' + searchResults.items.length);

    // Queue a set of commands to change the font for each found item.
    for (let i = 0; i < searchResults.items.length; i++) {
        searchResults.items[i].font.color = 'orange';
        searchResults.items[i].font.highlightColor = 'black';
        searchResults.items[i].font.bold = true;
    }
    
    // Synchronize the document state by executing the queued commands, 
    // and return a promise to indicate task completion.
    await context.sync();
});  
// Search using a wildcard
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
    
    // Queue a command to search the document with a wildcard
    // for any string of characters that starts with 'to' and ends with 'n'.
    const searchResults = context.document.body.search('to*n', {matchWildcards: true});

    // Queue a command to load the search results and get the font property values.
    searchResults.load('font');
    
    // Synchronize the document state by executing the queued commands, 
    // and return a promise to indicate task completion.
    await context.sync();
    console.log('Found count: ' + searchResults.items.length);

    // Queue a set of commands to change the font for each found item.
    for (let i = 0; i < searchResults.items.length; i++) {
        searchResults.items[i].font.color = 'purple';
        searchResults.items[i].font.highlightColor = 'pink';
        searchResults.items[i].font.bold = true;
    }
    
    // Synchronize the document state by executing the queued commands, 
    // and return a promise to indicate task completion.
    await context.sync();
}); 

load(propertyNames)

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

load(propertyNames?: string | string[]): Word.SearchOptions;

パラメーター

propertyNames

string | string[]

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

戻り値

load(propertyNamesAndPaths)

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

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Word.SearchOptions;

パラメーター

propertyNamesAndPaths

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

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

戻り値

newObject(context)

Wordの新しいインスタンスを作成します。SearchOptions オブジェクト

static newObject(context: OfficeExtension.ClientRequestContext): Word.SearchOptions;

パラメーター

戻り値

set(properties, options)

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

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

パラメーター

properties
Word.Interfaces.SearchOptionsUpdateData

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

options
OfficeExtension.UpdateOptions

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

戻り値

void

set(properties)

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

set(properties: Word.SearchOptions): void;

パラメーター

properties
Word.SearchOptions

戻り値

void

toJSON()

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

toJSON(): Word.Interfaces.SearchOptionsData;

戻り値