Microsoft Developer Network > Forenhomepage > Visual Studio Tools for Office > How to import a paragraph selected from Microsoft Word 2007 to add-in?
Stellen Sie eine FrageStellen Sie eine Frage
 

BeantwortetHow to import a paragraph selected from Microsoft Word 2007 to add-in?

  • Freitag, 3. Juli 2009 12:35Sunrise VN TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Hi all,
    I'm writing a add-in for Microsoft Word 2007. A problem is happen, I don't know how to import a paragraph selected from Microsoft Word 2007  to my add-in. Help me please!
    Thanks all!

Antworten

  • Montag, 6. Juli 2009 14:15Cindy MeisterMVP, ModeratorTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet
    I still do not understand what you want help with.

    FWIW VSTO provides no way for you to assign a keyboard shortcut to a command in your add-in. Keyboard shortcuts can only be mapped to VBA macros within a Word document. If you want to link the keyboard to your add-in you must use the Windows API to hook into the keyboard messaging.
    Cindy Meister, VSTO/Word MVP

Alle Antworten

  • Samstag, 4. Juli 2009 10:32Cindy MeisterMVP, ModeratorTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Please provide more information. I don't understand what you mean by "importa a paragraph to [your] add-in." What, more specifically, do you need to do with the paragraph the user has selected in the document?
    Cindy Meister, VSTO/Word MVP
  • Montag, 6. Juli 2009 13:19Sunrise VN TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Please provide more information. I don't understand what you mean by "importa a paragraph to [your] add-in." What, more specifically, do you need to do with the paragraph the user has selected in the document?
    Cindy Meister, VSTO/Word MVP

    Instead of copying and paste a paragraph to my add-in, user can select a paragraph and press Ctrl + right mouse click it will auto importing to my add-in
  • Montag, 6. Juli 2009 14:15Cindy MeisterMVP, ModeratorTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet
    I still do not understand what you want help with.

    FWIW VSTO provides no way for you to assign a keyboard shortcut to a command in your add-in. Keyboard shortcuts can only be mapped to VBA macros within a Word document. If you want to link the keyboard to your add-in you must use the Windows API to hook into the keyboard messaging.
    Cindy Meister, VSTO/Word MVP
  • Dienstag, 7. Juli 2009 03:26Sunrise VN TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    That is my problem. I don't know how to use the Windows API to hook into the keyboard messaging. Can you help me?
    Thanks!
  • Donnerstag, 9. Juli 2009 06:09Rabinarayan Biswal TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Vorgeschlagene AntwortEnthält Code
    Hi

    If I understood you question, you want to get some selected text from a Word document in your add-in and process it .

    you can write a function that reads selected text from the document and returns a string . 
            private string GetDocumentText()
            {
                try
                {
                    Word.Selection s = this.Application.Selection;
                    return s.Text;
                }
                catch
                {
                    System.Windows.Forms.MessageBox.Show("Error reading document !");
                }
    
                return string.Empty;
            }
    
    

  • Donnerstag, 9. Juli 2009 07:13Tim LiMSFT, ModeratorTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Hello,

    Here's a sample of working with Windows API in VSTO please check it out:
    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/74a87306-f7ea-4410-9cbb-6d772d94c8c2/

    Thanks
    We have published a VSTO FAQ recently, you can view them from the entry thread VSTO FAQ.
    If you have any feedbacks or suggestions on this FAQ, please feel free to write us emails to colbertz@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.