tags:

views:

51

answers:

1

Hi! I just trying to made word add-ins that gone save opened document.I made ribbon and button on it.Below is the that i use for saving word document on certain location:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles Button1.Click
        Dim ThisApplication As Word.Application
        ThisApplication.ActiveDocument.SaveAs("C:\email")
        ThisApplication.Quit()
        ThisApplication= Nothing
        End Sub

But when i click on this button i just made email.doc but that document does not contain any content of the opened document, it just made new doc file.

What i am doing wrong? The event on this button need to just same as event on standard Word save button, so how i can do this?

+2  A: 

I can only imagine that maybe you need to create an object to represent the document itself first. Try the following:

Dim ThisApplication As Word.Application
Dim oDoc As Word.Document = ThisApplication.ActiveDocument
oDoc.SaveAs("C:\email")
oDoc.Close()        
ThisApplication.Quit()
oDoc = Nothing
ThisApplication = Nothing
Tychumsempir