すべてのプロダクト
Search
ドキュメントセンター

Intelligent Media Management:コメント

最終更新日:Dec 27, 2024

このトピックでは、テキストドキュメントのコメントオブジェクトに関連するAPI操作について説明します。

コメント

ActiveDocument.Comments

ドキュメントからすべてのコメントを取得します。

重要

JS-SDK V1.1.10以降でのみこの機能がサポートされています。

  • 構文

    expression.ActiveDocument.Comments

    expression: ドキュメントタイプのアプリケーションオブジェクト。

  • async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // すべてのコメントを取得します。
      const Comments = await app.ActiveDocument.Comments;
    }

メソッド

ActiveDocument.Comments.Add()

コメントを追加します。

重要

JS-SDK V1.1.10以降でのみこの機能がサポートされています。

  • 構文

    expression. ActiveDocument.Comments.Add({ Range, Text })

    expression: ドキュメントタイプのアプリケーションオブジェクト。

  • パラメーター

    パラメーター

    タイプ

    必須

    説明

    Range

    Object

    はい

    コメントを追加する範囲。

    Text

    String

    はい

    コメントの内容。

  • Rangeの説明

    パラメーター

    タイプ

    必須

    説明

    Start

    Number

    はい

    コメントを追加する範囲の開始位置。

    End

    Number

    はい

    コメントを追加する範囲の終了位置。

  • async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // すべてのコメントを取得します。
      const comments = await app.ActiveDocument.Comments;
    
      // コメントを追加します。
      await comments.Add({
        Range: {
          Start: 0,
          End: 9,
        },
        Text: 'Aliyun comment',
      });
    }

ActiveDocument.Comments.DeleteComment()

位置に基づいて指定されたコメントを削除します。

重要

JS-SDK V1.1.10以降でのみこの機能がサポートされています。

  • 構文

    expression. ActiveDocument.Comments.DeleteComment({ Start, Length })

    expression: ドキュメントタイプのアプリケーションオブジェクト。

  • パラメーター

    パラメーター

    タイプ

    必須

    説明

    Start

    Number

    はい

    コメントの開始位置。

    Length

    Number

    はい

    コメントテキストの長さ。単位:バイト。

  • //@file=base.docx
    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // コメントオブジェクト。
      const comments = await app.ActiveDocument.Comments;
    
      // コメントを追加します。
      await comments.Add({
        Range: {
          Start: 0,
          End: 9,
        },
        Text: 'Comment',
      });
    
      // コメントを削除します。
      await comments.DeleteComment({
        Start: 0,
        Length: 9,
      });
    }

ActiveDocument.Comments.DeleteCommentById()

説明

最初にドキュメント内のすべてのコメントを取得し、目的のコメントのIDを確認できます。

IDを指定してコメントを削除します。

重要

JS-SDK V1.1.19以降でのみこの機能がサポートされています。

  • 構文

    expression.ActiveDocument.Comments.DeleteCommentById({ CommentId })

    expression: アプリケーションオブジェクト。

  • パラメーター

    パラメーター

    タイプ

    必須

    説明

    CommentId

    String

    はい

    コメントのID。ActiveDocument.GetCommentsを呼び出すことで、ドキュメント内のすべてのコメント(コメントIDを含む)を取得できます。

  • async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // ドキュメント内のコメントを取得します。
      const comments = await app.ActiveDocument.Comments;
    
      // 指定されたコメントを削除します。
      await comments.DeleteCommentById({
        CommentId: '1234567890'
      });
    }

ActiveDocument.Comments.GetCommentReferenceText()

コメントの参照テキストを取得します。

重要

JS-SDK V1.1.19以降でのみこの機能がサポートされています。

  • 構文

    expression.ActiveDocument.Comments.GetCommentReferenceText({ CommentId })

    expression: アプリケーションオブジェクト。

  • パラメーター

    パラメーター

    タイプ

    必須

    説明

    CommentId

    String

    はい

    コメントのID。 ActiveDocument.GetCommentsを呼び出すことで、ドキュメント内のすべてのコメント(コメントIDを含む)を取得できます。

  • async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // ドキュメント内のコメントを取得します。
      const comments = await app.ActiveDocument.Comments;
    
      // 指定されたコメントの参照テキストを取得します。
      await comments.GetCommentReferenceText({
        CommentId: '1234567890'
      });
    }

ActiveDocument.Comments.GoToComment()

指定されたコメントにジャンプします。

重要

JS-SDK V1.1.19以降でのみこの機能がサポートされています。

  • 構文

    expression.ActiveDocument.Comments.GoToComment({ CommentId })

    expression: アプリケーションオブジェクト。

  • パラメーター

    パラメーター

    タイプ

    必須

    説明

    CommentId

    String

    はい

    コメントのID。ActiveDocument.GetCommentsを呼び出すことで、ドキュメント内のすべてのコメント(コメントIDを含む)を取得できます。

  • async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // ドキュメント内のコメントを取得します。
      const comments = await app.ActiveDocument.Comments;
    
      // コメントにジャンプします。
      await comments.GoToComment({
        CommentId: '1234567890'
      });
    }

ActiveDocument.Comments.ModifyComment()

指定されたコメントの内容を変更します。

重要

JS-SDK V1.1.19以降でのみこの機能がサポートされています。

  • 構文

    expression.ActiveDocument.Comments.ModifyComment({ CommentId, Text })

    expression: アプリケーションオブジェクト。

  • パラメーター

    パラメーター

    タイプ

    必須

    説明

    CommentId

    String

    はい

    コメントのID。ActiveDocument.GetCommentsを呼び出すことで、ドキュメント内のすべてのコメント(コメントIDを含む)を取得できます。

    Text

    String

    はい

    新しいコメント。

  • async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // ドキュメント内のコメントを取得します。
      const comments = await app.ActiveDocument.Comments;
    
      // 指定されたコメントの内容を変更します。
      await comments.ModifyComment({
        CommentId: '1234567890',
        Text: 'New comment content'
      });
    }

ActiveDocument.Comments.ReplyComment()

コメントに返信を追加します。

重要

JS-SDK V1.1.14以降でのみこの機能がサポートされています。

  • 構文

    expression. ActiveDocument.Comments.ReplyComment({ CommentId, Text })

    expression: ドキュメントタイプのアプリケーションオブジェクト。

  • パラメーター

    パラメーター

    タイプ

    必須

    説明

    CommentId

    String

    はい

    返信先のコメントのID。ActiveDocument.GetCommentsを使用して、CommentIdを含むコメントを取得できます。

    Text

    String

    はい

    返信の内容。

  • 戻り値

    WebOffice V4.2.1以降では、コメントデータの返却がサポートされています。

  • async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // ドキュメント内のすべてのコメントを取得します。
      const comments = await app.ActiveDocument.Comments;
    
      // コメントを追加します。
      await comments.Add({
        Range: {
          CommentId: 0,
          End: 9,
        },
        Text: 'Aliyun comment',
      });
    
      // 最初のコメントを取得します。
      const comments = await WPSOpenApi.Application.ActiveDocument.GetComments();
      const firstCommentId = comments[0].commentId;
    
      // コメントに返信します。
      await comments.ReplyComment({
        CommentId: firstCommentId,
        Text: 'Reply to the first comment',
      });
    }