none
Opening/Modifying outlook mailitem using inspector .get_WordEdiotr() gives operation abort error RRS feed

  • Question

  • Hi i am opening outlook mail(which contains a table) through powerpoint 2007 addin  but again and again i  am getting Operation aborted error in inspector .get_WordEdiotr()
    Its working on few machines but in some machines it gives error..
    Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) at Microsoft.Office.Interop.Outlook.InspectorClass.get_WordEditor()
     
    here is a small code snippet..
    omsg contains a table with a calendar whose date needs to be modified
    Dim inspect As Outlook.Inspector = oMsg.GetInspector()   
    If inspect.IsWordMail = True And inspect.EditorType = Outlook.OlEditorType.olEditorWord Then
      Dim document As Microsoft.Office.Interop.Word.Document = CType(inspect.WordEditor(), Microsoft.Office.Interop.Word.Document)
       For Each cntntcntrl As Microsoft.Office.Interop.Word.ContentControl In document.ContentControls
                 If cntntcntrl.Type = Word.WdContentControlType.wdContentControlDate Then
                      cntntcntrl.Range.Text = DateTime.Now.ToShortDateString()
                  End If
          Next
     End If
    Monday, February 4, 2013 5:20 AM

Answers

  • how can this particular code work at all?

    you declare variable of type Outlook.Application and immediatly after thaty you call on it some methods - where is binding of that variable to anything? Is this _whole_ code for outlook interaction?

    Monday, February 4, 2013 11:24 AM
  • put here only lines that have to do with outlook interaction, but ALL of them and in right sequence, just like in your code. I cannot make suggestions what is wrong if i see that that i know 100% is not working.
    Monday, February 4, 2013 11:38 AM

All replies

  • I assume that outlook version is also 2007? show us more code, how do you gain access to that mail and to outlook instance.

    Monday, February 4, 2013 8:36 AM
  •  yes outlook 2007 

     Dim oApp As Outlook.Application

    System.Runtime.InteropServices.Marshal.ReleaseComObject(oApp)

    Dim oMsg As Outlook._MailItem
     oMsg = CType(oApp.CreateItemFromTemplate(<path of oft file with table(having calendar>), Outlook.MailItem)

    Monday, February 4, 2013 9:22 AM
  • are you sure this is the code you wanted to show us? i see only declaration of variable and releasing it, no idea how this code could work. Maybe just paste here whole function or class responsible for outlook interaction
    Monday, February 4, 2013 10:06 AM
  • Dim oApp As Outlook.Application

    System.Runtime.InteropServices.Marshal.ReleaseComObject(oApp)

    Dim oMsg As Outlook._MailItem
     oMsg = CType(oApp.CreateItemFromTemplate(<path of oft file with table(having calendar>), Outlook.MailItem)

    Dim inspect As Outlook.Inspector = oMsg.GetInspector()   
    If inspect.IsWordMail = True And inspect.EditorType = Outlook.OlEditorType.olEditorWord Then
      Dim document As Microsoft.Office.Interop.Word.Document = CType(inspect.WordEditor(), Microsoft.Office.Interop.Word.Document)
       For Each cntntcntrl As Microsoft.Office.Interop.Word.ContentControl In document.ContentControls
                 If cntntcntrl.Type = Word.WdContentControlType.wdContentControlDate Then
                      cntntcntrl.Range.Text = DateTime.Now.ToShortDateString()
                  End If
          Next

     End If

    Its working on few machines but in some machines it gives error..

    Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) at Microsoft.Office.Interop.Outlook.InspectorClass.get_WordEditor()

    the exception is thrown in this line:-

     Dim document As Microsoft.Office.Interop.Word.Document = CType(inspect.WordEditor(), Microsoft.Office.Interop.Word.Document)

    I hope this is more than enough to understand the problem ...The problem is with inspector .WordEditor()...

    code is working  fine on few machines 


    Monday, February 4, 2013 11:11 AM
  • how can this particular code work at all?

    you declare variable of type Outlook.Application and immediatly after thaty you call on it some methods - where is binding of that variable to anything? Is this _whole_ code for outlook interaction?

    Monday, February 4, 2013 11:24 AM
  • i have just put the error prone code .............else its a huge code 
    Monday, February 4, 2013 11:30 AM
  • put here only lines that have to do with outlook interaction, but ALL of them and in right sequence, just like in your code. I cannot make suggestions what is wrong if i see that that i know 100% is not working.
    Monday, February 4, 2013 11:38 AM