Показывать всплывающие подсказки при открытии документа Word в C # - PullRequest
3 голосов
/ 02 июня 2011

Я сделал небольшую функцию, которая открывает 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

TO

enter image description here

1 Ответ

5 голосов
/ 07 июля 2011
 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

...