Click here to Skip to main content
15,895,142 members
Home / Discussions / C#
   

C#

 
AnswerRe: Send SMS Messages Pin
BillWoodruff23-Oct-14 6:51
professionalBillWoodruff23-Oct-14 6:51 
QuestionHow do I use this class Pin
MarkB12323-Oct-14 2:12
MarkB12323-Oct-14 2:12 
AnswerRe: How do I use this class Pin
Richard MacCutchan23-Oct-14 2:35
mveRichard MacCutchan23-Oct-14 2:35 
AnswerRe: How do I use this class Pin
OriginalGriff23-Oct-14 2:38
mveOriginalGriff23-Oct-14 2:38 
GeneralRe: How do I use this class Pin
MarkB12323-Oct-14 2:57
MarkB12323-Oct-14 2:57 
GeneralRe: How do I use this class Pin
OriginalGriff23-Oct-14 3:02
mveOriginalGriff23-Oct-14 3:02 
GeneralRe: How do I use this class Pin
MarkB12323-Oct-14 3:12
MarkB12323-Oct-14 3:12 
GeneralRe: How do I use this class Pin
Richard MacCutchan23-Oct-14 5:23
mveRichard MacCutchan23-Oct-14 5:23 
AnswerRe: How do I use this class Pin
BillWoodruff23-Oct-14 3:34
professionalBillWoodruff23-Oct-14 3:34 
AnswerRe: How do I use this class Pin
jschell23-Oct-14 8:45
jschell23-Oct-14 8:45 
QuestionTeamviewer Protocol Pin
Jassim Rahma22-Oct-14 23:11
Jassim Rahma22-Oct-14 23:11 
AnswerRe: Teamviewer Protocol Pin
Pete O'Hanlon22-Oct-14 23:48
mvePete O'Hanlon22-Oct-14 23:48 
AnswerRe: Teamviewer Protocol Pin
Richard MacCutchan23-Oct-14 0:31
mveRichard MacCutchan23-Oct-14 0:31 
GeneralRe: Teamviewer Protocol Pin
Jassim Rahma23-Oct-14 1:26
Jassim Rahma23-Oct-14 1:26 
GeneralRe: Teamviewer Protocol Pin
Richard MacCutchan23-Oct-14 2:30
mveRichard MacCutchan23-Oct-14 2:30 
AnswerRe: Teamviewer Protocol Pin
Thomas Mahlberg23-Oct-14 6:13
professionalThomas Mahlberg23-Oct-14 6:13 
Question"This command is not available because no document is open." Pin
Tejas Shastri22-Oct-14 12:13
Tejas Shastri22-Oct-14 12:13 
Using this code. What am I doing wrong? This is my first Add-in and I'm still learning C#, so please forgive stupid mistakes. Thanks.


C#
private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            this.Application.DocumentChange += new ApplicationEvents4_DocumentChangeEventHandler(Application_DocumentChange);
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }

        private void Application_DocumentChange()
        {

            this.Application.ActiveDocument.TrackRevisions = true;
            int n = this.Application.ActiveDocument.Revisions.Count;
            Word.Range[] change = new Word.Range[n];
            for (int i = 0; i < n; i++)
            {
                change[i] = this.Application.ActiveDocument.Revisions[i].Range;
                change[i].Select();
                change[i].Copy();
                string changed = Clipboard.GetText(TextDataFormat.Text);
                MessageBox.Show(changed);
            }
        }


The event handler gets called even before the document is opened.. thats the problem.. Document change occurs when a documentis opened(old/new) right?

Error is in the line:
change[i] = this.Application.ActiveDocument.Revisions[i].Range;


modified 23-Oct-14 2:03am.

AnswerRe: "This command is not available because no document is open." Pin
Richard Andrew x6422-Oct-14 13:04
professionalRichard Andrew x6422-Oct-14 13:04 
GeneralRe: "This command is not available because no document is open." Pin
Tejas Shastri23-Oct-14 0:45
Tejas Shastri23-Oct-14 0:45 
GeneralRe: "This command is not available because no document is open." Pin
Richard Andrew x6423-Oct-14 1:34
professionalRichard Andrew x6423-Oct-14 1:34 
GeneralRe: "This command is not available because no document is open." Pin
Tejas Shastri23-Oct-14 2:12
Tejas Shastri23-Oct-14 2:12 
GeneralRe: "This command is not available because no document is open." Pin
Richard Andrew x6423-Oct-14 2:22
professionalRichard Andrew x6423-Oct-14 2:22 
GeneralRe: "This command is not available because no document is open." Pin
Tejas Shastri23-Oct-14 2:23
Tejas Shastri23-Oct-14 2:23 
AnswerRe: "This command is not available because no document is open." Pin
Pete O'Hanlon23-Oct-14 0:49
mvePete O'Hanlon23-Oct-14 0:49 
GeneralRe: "This command is not available because no document is open." Pin
Tejas Shastri23-Oct-14 0:54
Tejas Shastri23-Oct-14 0:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.