locked
Call was rejected by callee. (Exception from HRESULT:0x80010001(RPC_E_CALL_REJECTED))

    Question

  • I am getting the above error on a VB program (Using VB 2008) that has been running perfectly on an XP based PC. I have this week changed to a new Windows 7 PC and also downloaded VB 2010 for the first time. Because Office 2003 is not supported by Windows 7 I have also bought Office 2010 Home & Student version. Now I run this program for the first time and get the above error message. I had an earlier problem that was related to pathnames of files (Difference between the old PC and the new one) which is the only change I have made and that was on a parameter file anyway. The code has not changed at all between versions. When stepping into the program the PC bleeps at the 1st instruction within the TRY objSheet = objExcel.Workbooks.Open(builder.ToString()).Worksheets.Item(1) but carries on then when it gets to the instruction  objSheet1 = obj1Excel.Workbooks.Open(builder.ToString()).Worksheets.Item(1) the program jumps to the Catch exception.

    The full error message is as follows:

    Call was rejected by callee. (Exception from HRESULT:0x80010001(RPC_E_CALL_REJECTED))

    System.Runtime.InteropServices.COMException was caught
      ErrorCode=-2147418111
      Message=Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))
      Source=Microsoft.Office.Interop.Excel
      StackTrace:
           at Microsoft.Office.Interop.Excel.WorkbookClass.get_Worksheets()
           at Green_Fees_Update.Form1.okButton_Click(Object sender, EventArgs e) in C:\Users\Dave\Documents\Visual Studio 2008\Projects\Green_Fees\Green_Fees_Update\Green_Fees_Update\Form1.vb:line 120
      InnerException:

    If anyone has any idea as to what I am doing wrong I would appreciate their suggestions.

    Thanks

    Dave

    builder = New System.Text.StringBuilder()
            builder.Append(String.Format(inPathname))
            builder.Append(String.Format(inFilename))
            remainder = 0
            Try
                objSheet = objExcel.Workbooks.Open(builder.ToString()).Worksheets.Item(1)
                objExcel.Range("A16:AK381").Select()
                objData = objExcel.Selection
                Me.Refresh()
                row = 1
                firstRow = 0
                lastRow = 0
                col = 1
                yyyy = Mid(objData.Cells(row, col).Value, 7, 4)
                remainder = yyyy Mod 4
                If remainder = 0 Then
                    maxRow = 366
                Else
                    maxRow = 365
                End If
                Do While row <= maxRow
                    mm = Mid(objData.Cells(row, col).Value, 4, 2)
                    If mm = monthNo Then
                        If firstRow = 0 Then
                            firstRow = row
                        End If
                    End If
                    If mm > monthNo Then
                        Exit Do
                    End If
                    row = row + 1
                    If row > 366 Then
                        Exit Do
                    End If
                Loop
                lastRow = row - 1
                builder = New System.Text.StringBuilder()
                builder.Append(String.Format(file_Pathname.Text))
                builder.Append(String.Format(fileName.Text))
                astring = builder.ToString
                bstring = fileName.Text
                Dim files() As String = Directory.GetFiles(file_Pathname.Text)
                For Each filename As String In files
                    Dim file As New FileInfo(filename)
                    If file.Name = bstring Then
                        objSheet1 = obj1Excel.Workbooks.Open(builder.ToString()).Worksheets.Item(1)
                        If remainder = 0 Then
                            obj1Excel.Range("A16:AK381").Select()
                        Else
                            obj1Excel.Range("A16:AK380").Select()
                        End If
                        objData1 = obj1Excel.Selection
                        Me.Refresh()
                        col = 3
                        Do While firstRow <= lastRow
                            Do While col < 38
                                astring = objData.Cells(firstRow, col).Formula
                                If Microsoft.VisualBasic.Left((astring), 1) = "=" Then
                                    col = col + 1
                                    If col = 33 Then
                                        col = col + 1
                                    End If
                                End If
                                objData1.Cells(firstRow, col) = objData.Cells(firstRow, col).Value
                                col = col + 1
                            Loop
                            firstRow = firstRow + 1
                            col = 3
                            Me.Refresh()
                        Loop
                        sheet1Exists = True
                        Exit For
                    End If
                Next
                objData1.Cells(389, 3) = monthNo
                obj1Excel.Range("A15").Select()
                obj1Excel.Workbooks.Item(1).RefreshAll()
            Catch exp As Exception
                MessageBox.Show(exp.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop)
            End Try


    DBurr


    • Edited by DBurr Tuesday, February 07, 2012 12:38 PM
    Tuesday, February 07, 2012 12:32 PM

Answers

  • Thanks for trying Paul, but neither of those make much sense to me. I am going to try to rewrite the code to see if I can achieve the same result another way.

    Dave


    DBurr

    • Marked as answer by DBurr Tuesday, February 21, 2012 1:12 PM
    Tuesday, February 07, 2012 4:18 PM

All replies