Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: "This command is not available because no document is open." Pin
Pete O'Hanlon23-Oct-14 2:28
mvePete O'Hanlon23-Oct-14 2:28 
GeneralRe: "This command is not available because no document is open." Pin
Tejas Shastri23-Oct-14 2:33
Tejas Shastri23-Oct-14 2:33 
GeneralRe: "This command is not available because no document is open." Pin
Pete O'Hanlon23-Oct-14 2:40
mvePete O'Hanlon23-Oct-14 2:40 
GeneralRe: "This command is not available because no document is open." Pin
Tejas Shastri23-Oct-14 4:08
Tejas Shastri23-Oct-14 4:08 
GeneralRe: "This command is not available because no document is open." Pin
Freak3023-Oct-14 3:56
Freak3023-Oct-14 3:56 
GeneralRe: "This command is not available because no document is open." Pin
Tejas Shastri23-Oct-14 4:09
Tejas Shastri23-Oct-14 4:09 
Questionlaunch another Application from memory by C# Pin
iscreen22-Oct-14 0:15
iscreen22-Oct-14 0:15 
AnswerRe: launch another Application from memory by C# Pin
Richard MacCutchan22-Oct-14 0:20
mveRichard MacCutchan22-Oct-14 0:20 
AnswerRe: launch another Application from memory by C# PinPopular
Richard Deeming22-Oct-14 2:45
mveRichard Deeming22-Oct-14 2:45 

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.