gpt4 book ai didi

c# - 在 C# 中打开 Word 文档时显示修订气球

转载 作者:行者123 更新时间:2023-11-30 15:07:49 26 4
gpt4 key购买 nike

我做了一个小函数,可以在给定的文件位置打开 WordDocument。我想在文档显示时启用气球。

这是目前的代码:

    public static Document OpenWordDocument(object fileName)
{
ApplicationClass application = new ApplicationClass();
object readOnly = false;
object isVisible = true;
object missing = Missing.Value;

application.Visible = true;
Document wordDocument = application.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);

wordDocument.TrackRevisions = true;
//Do something here the enable balloons
wordDocument.Activate();

return wordDocument;
}

enter image description here

enter image description here

最佳答案

 using Microsoft.Office.Interop.Word;

启用气球的主要属性是:

//enable tracking change
wordDocument.TrackRevisions = true;
wordDocument.ActiveWindow.View.MarkupMode = WdRevisionsMode.wdBalloonRevisions;

你也可以添加这些设置

//the balloon will be on the right side
wordDocument.ActiveWindow.View.RevisionsBalloonSide = WdRevisionsBalloonMargin.wdRightMargin;

// the ballon section width will been calculate in percent
wordDocument.ActiveWindow.View.RevisionsBalloonWidthType = WdRevisionsBalloonWidthType.wdBalloonWidthPercent;

//make sure the balloon will not been cut, the balloons section is egal to the doc with(100%)
wordDocument.ActiveWindow.View.RevisionsBalloonWidth = 100.0f;

//make sur Word show the final version with the revisions
wordDocument.ActiveWindow.View.RevisionsView = WdRevisionsView.wdRevisionsViewFinal;

//True for Microsoft Word to display revisions and comments that were made to a document with Track Changes enabled
wordDocument.ActiveWindow.View.ShowRevisionsAndComments = true;

//True for Microsoft Word to display insertions and deletions that were made to a document
wordDocument.ActiveWindow.View.ShowInsertionsAndDeletions = true;

请务必安装 Microsoft Word 2010 或 2007 以及最新的 Microsoft.Office.Interop.Word.dll

关于c# - 在 C# 中打开 Word 文档时显示修订气球,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6219017/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com