I have written a C# code in console application to open two excels and copy and paste data from one excel to another excel. It was working fine until the destination excel’s visibility was true. But I need to hide the excel at the time of execution. So I changed the visibility to false. Like,
_destExcelApp = new Excel.ApplicationClass();
_destExcelApp.Visible = false;
Now its showing an exception like
Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))
How to solve this one?
fat
6,3255 gold badges44 silver badges70 bronze badges
asked Dec 11, 2013 at 8:51
4
I ran into this same error being thrown when I deployed my application onto a machine without a fully activated and licensed installation of Excel. I spent hours trying to diagnose the issue. Make sure you check your Office installations to make sure they are complete.
answered Feb 19, 2014 at 21:33
Crash5998Crash5998
3365 silver badges12 bronze badges
4
I solved this behaviour with the help of this question:
Strange behaviour of «Call was rejected by callee.» exception with Excel
The issue was simply that the Workbook.Open
hadn’t finished when I gave a Worksheet.SaveAs
command. So sometimes, the script would work, sometimes not.
I simply added a pause in the script after Workbook.Open
and it worked. I went on to find a property Ready
, which allowed me to do exactly what I wanted:
$excel = New-Object -ComObject "Excel.Application" -ea Stop
$wb = $excel.Workbooks.Open($workbook)
$sheet = $wb.Sheets("List")
while (-not $excel.Ready) {
sleep 1
}
$sheet.SaveAs($csvpath,6)
So in my case, it had nothing to do with non-activated or corrupted Excel installations.
answered Jan 10, 2019 at 10:13
JoostJoost
1,1261 gold badge10 silver badges19 bronze badges
Ensure that MS Word/Excel is not showing a dialog box that needs a response.
I set a breakpoint on the line that caused the failure, then set .Visible
to true in PowerShell, to find this:
$word.Visible = $true
After I clicked ‘Yes’ and updated the settings, after I re-ran my scripted COM interactions, they succeeded.
answered Jan 9, 2018 at 0:07
CJBSCJBS
15.1k6 gold badges85 silver badges135 bronze badges
4
I was facing the same error and many solutions suggested were not working for me.
I had an application running in windows 8 and I found that the problem was Excel always asking to choose default application for «xlsx» extensions.
When executing the application no window dialog appeared, just the error was shown.
I solved the problem going to Control Panel > Programs > Default Programs and setting Microsoft Office Excel 2016 as default program for xlsx files.
Elmue
7,4422 gold badges46 silver badges57 bronze badges
answered Jun 5, 2017 at 14:55
4
I ran into this issue with Word and my solution was uninstalling OpenOffice. I’m not sure if there’s another solution but most likely has to do with the dlls and a conflict with the default file handler for the particular files you are generating programmatically.
answered May 12, 2015 at 11:10
amadibamadib
87014 silver badges33 bronze badges
1
Are you copying a range of information from one document to another, or are you going back and forth between the 2 documents copying cell by cell? Excel is single threaded, so if you go back and forth, it could cause this issue.
answered Dec 11, 2013 at 16:50
2
Ran into this problem on my machine. Excel is fully activated and already the default program for .xlsx files. I was loading a workbook template I created with pivot tables and having a script update the data in the tables. Turns out that if the pivot tables are set to «Refresh data when opening the file» under Pivot Table Options > Data, it causes some sort of threading contention issues.
Disabling the refresh on opening solved the issue.
answered Nov 13, 2018 at 18:14
In my case, I simply restarted my machine and found out that there was a windows update pending. Restarting the machine solved my problem.
answered Apr 5, 2019 at 18:51
RitziesRitzies
331 silver badge7 bronze badges
I agree with those that say excel license must be activated, I had the same problem and I activated the license everything works fine — Papiki
answered Feb 26, 2020 at 6:06
I encountered this Error today in Excel 2016.
We found out that the computer with this problem had some add-ins activated.
Strangely that one pc took ages to start excel. after deactivating the add-ins our program worked fine.
Strangely we couldn´t reproduce this on our dev pc´s.
answered Feb 6, 2018 at 12:33
Martin H.Martin H.
1333 silver badges8 bronze badges
I have the same problem. I ran the program on «Windows XP x86» and it crashed with a similar error. The problem was in the line:
sheetSource.Cells(i, iColumn).Interior.Color = RGB(255, 255, 0)
Multiple executions of this line resulted in a crash. When I deleted it immediately everything started working fine.
answered Jan 15, 2021 at 12:53
PavelPavel
111 bronze badge
I can offer another thing to look out for in addition to the solutions above, which seem to converge on this comment (on an answer by Alielson Piffer),
SUMMARY: So by the answers here we could conclude that this error may occur when Excel is showing any message in a popup window like for example "This software is not activated" or "Do you want Excel to be the default application for DOCX files?". – Elmue Jun 12 '17 at 22:43
There were no open messageboxes or prompts but there was an unended process (Word.exe in my case) in task manager that I needed to end. That fixed it.
This would explain why a restart helped another user.
answered Jun 5, 2020 at 7:13
M HM H
1482 silver badges8 bronze badges
Make sure you check your Office installations to make sure they are complete.
otherwise try following
try App visibleity false
after the all Data is writin then
turn on the Visibility
ex
Dim wapp As new excel.Application
….
.
.
wapp.Visible = false
‘do your writing
..
.
.
.
.
‘then turn on your visibility
wapp.Visible = True
answered Jun 12, 2020 at 6:59
1
Hey Everyone hoping someone can help me I am at a dead end. Here is the scenario:
When we merge a document thru our database to send to efiling we are getting an error message stating Call was rejected by callee (RPC_E_CALL_REJECTED).
Now we only get this error message if we have any images in the document. If we take the state seal and the signature box out of the document everything works fine.
We have tried with only image different images different file types of images. Any image fails and creates this error.
What is happening is the document is being created in Word on the local machine, then once created and the save button is selected the database program uses the word 2010 export to pdf and creates the pdf which it them saves. This is where the error happens, and only happens with images in the documents.
We cannot change the way the pdf is exported as that is coded into the program we use.
Attached is the entire error we are getting. The client tool is what helps us get the efiling done and is part of the database program.
Any ideas would be welcomed
Thanks,
Phil
attach_file
Attachment
error.png
250 KB
- Remove From My Forums
-
Question
-
I have a VB program that creates Word documents automatically. It has worked perfectly fine through prior versions of Windows and Word. We recently switched to Windows 8.1 and Word 2013. When creating a Word document, I get the error message «-2147418111,
Call was rejected by callee»A portion of my code is below:
Imports System
Imports System.IO
Imports System.Text
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.WordPublic Class frmCreateDocs
Public wdObj As Word.Application
Public wdUnits1 As WdUnits = WdUnits.wdStory
Public wdBk As WdGoToItem = WdGoToItem.wdGoToBookmark
Public wdFmt As WdDocumentType = WdDocumentType.wdTypeDocument
Public wdChar As WdUnits = WdUnits.wdCharacter
Public wdLine1 As WdUnits = WdUnits.wdLine
Public wdPara As WdUnits = WdUnits.wdParagraph
Public wdExt As WdMovementType = WdMovementType.wdExtendWith wdObj
DocName = SetTemplate & «Lgl2010.dotx»
.Documents.Add(Template:=SetTemplate & «Lgl2010.dotx», NewTemplate:=False, DocumentType:=WdDocumentType.wdTypeDocument)
DocName = SetDir & «TrustAmend.docx»
.Documents.Open(FileName:=SetDir & «TrustAmend.docx», ReadOnly:=True)
.Selection.EndKey(wdUnits1, Extend:=wdExt)
.Selection.Copy()
.ActiveDocument.Close()
.Selection.Paste()
End WithThe error seems to occur when the .Selection.Endkey command is run.
Any suggestions?
Don Murray
Answers
-
Hello Don,
Try to use the following line of code instead:
Selection.EndKey(Unit:=wdUnits, Extend:=wdExtend)
-
Marked as answer by
Monday, February 2, 2015 5:25 PM
-
Marked as answer by
Solution 1
I ran into this same error being thrown when I deployed my application onto a machine without a fully activated and licensed installation of Excel. I spent hours trying to diagnose the issue. Make sure you check your Office installations to make sure they are complete.
Solution 2
I solved this behaviour with the help of this question:
Strange behaviour of «Call was rejected by callee.» exception with Excel
The issue was simply that the Workbook.Open
hadn’t finished when I gave a Worksheet.SaveAs
command. So sometimes, the script would work, sometimes not.
I simply added a pause in the script after Workbook.Open
and it worked. I went on to find a property Ready
, which allowed me to do exactly what I wanted:
$excel = New-Object -ComObject "Excel.Application" -ea Stop
$wb = $excel.Workbooks.Open($workbook)
$sheet = $wb.Sheets("List")
while (-not $excel.Ready) {
sleep 1
}
$sheet.SaveAs($csvpath,6)
So in my case, it had nothing to do with non-activated or corrupted Excel installations.
Solution 3
Ensure that MS Word/Excel is not showing a dialog box that needs a response.
I set a breakpoint on the line that caused the failure, then set .Visible
to true in PowerShell, to find this:
$word.Visible = $true
After I clicked ‘Yes’ and updated the settings, after I re-ran my scripted COM interactions, they succeeded.
Solution 4
I was facing the same error and many solutions suggested were not working for me.
I had an application running in windows 8 and I found that the problem was Excel always asking to choose default application for «xlsx» extensions.
When executing the application no window dialog appeared, just the error was shown.
I solved the problem going to Control Panel > Programs > Default Programs and setting Microsoft Office Excel 2016 as default program for xlsx files.
Solution 5
I ran into this issue with Word and my solution was uninstalling OpenOffice. I’m not sure if there’s another solution but most likely has to do with the dlls and a conflict with the default file handler for the particular files you are generating programmatically.
Related videos on Youtube
03 : 38
Replace Error Code With Exception
01 : 54
The data necessary to complete this operation is not yet available. (Exception HRESULT: 0x8000000A)
29 : 44
Part 40 C# Tutorial Exception Handling in C#
01 : 58
How To Fix Unhandled Exception Has Occurred In Your Application Error On Windows 10 / 8 /7 / 8.1
01 : 49
User canceled out of save dialog (Exception from HRESULT: 0x8004000C (OLE_E_PROMPTSAVECANCELLED))
11 : 01
Exception Handling | C# | Tutorial 24
03 : 30
Solved: Excel Pastespecial Error HResult 0x800A03EC after copy
CodeDocu Developer C# Asp Net Angular
02 : 07
HRESULT E_FAIL has been Returned from a Call to a Com Component | Add Reference Visual Studio Error
01 : 25
Solved — Exception from HRESULT: 0xC0014041 (Microsoft.SqlServer.DTSRuntimeWrap)
05 : 01
Comments
-
I have written a C# code in console application to open two excels and copy and paste data from one excel to another excel. It was working fine until the destination excel’s visibility was true. But I need to hide the excel at the time of execution. So I changed the visibility to false. Like,
_destExcelApp = new Excel.ApplicationClass(); _destExcelApp.Visible = false;
Now its showing an exception like
Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))
How to solve this one?
-
did you try with:
... = new Excel.Application();
?? -
Are you using
.Activate
or.Select
anywhere? Which line gives you the error? -
I need ApplicationClass to run macro in destination excel. ApplicationClass and Application are same?
-
No I didn’t use any such things.. The error is coming while getting all worksheets in the excel i.e. excelSheets = _destExcelWorkbook.Worksheets;
-
-
So you’re suggesting that the exception is being raised because of unactivated and unlicensed Excel and that activating it would fix that issue. Sounds odd. Btw welcome to Stack Overflow.
-
@BleedingFingers, yes. I ran into a situation where this exception was thrown, and another function of my application threw a separate error relating to «reduced functionality mode.» Re-installation and activation of Excel resolved both issues.
-
I’ve been experiencing the same issue with an unactivated version of Excel. I think in general it’s caused by Excel being busy at the time you invoke it — that could be because it’s attempting to show a dialogue warning that you don’t have a valid license, or maybe you’re attempting to open a spreadsheet with links and the linked spreadsheet isn’t available etc. I think in general the solution is to implement IMessageFilter as mentioned above (I’ve not tried this yet). I’ve worked around it by opening spreadsheets readonly, with links disabled etc.
-
This answer is nonsense. It is absolutely no problem to work with multiple worksheets in Excel automation.
-
SUMMARY: So by the answers here we could conclude that this error may occur when Excel is showing any message in a popup window like for example «This software is not activated» or «Do you want Excel to be the default application for DOCX files?».
-
Yeah! I think that was exactly the problem, @Elmue. Though, for Excel must be XLSX files.
-
Probably you did not analyze this problem thoroughly. OpenOffice neither depends on DLLs from Microsoft Office nor vice versa. So your conclusion with a DLL conflict is surely wrong. What happend probably is that Excel asked you if you want to open XLSX files with Microsoft Excel because your default program for XLSX files was OpenOffice. See the answer from Alielson Piffer who solved this problem without unstalling OpenOffice. Whenever Excel opens a popup at startup you may get error RPC_E_CALL_REJECTED or VBA_E_IGNORE or DISP_E_EXCEPTION.
-
You are right. The question is about Excel, not Word.
-
Actually, my problem happened when I was working with a Word file. But since the problem appear to be the same for Office files, I agree it would be easier if I just say about Excel instead. Thanks for the help, @Elmue!
-
Yes, thanks, some of my DocxManager (document manager for MS Word with tags, tabs, etc) users reported the
Call was rejected by callee
error in such situations. This should be the root of such issue, not that Word’s not the default program as described in another answer. -
This is happening to me in Windows 10. When I click Yes, it just tells me I have to do it myself in Settings. I don’t know which extensions besides doc and docx it wants. This is stupid.
-
@Arrow_Raider — it doesn’t matter what the configuration is; what matters is that the dialog doesn’t show (because it interferes with the automation). When the dialog appears, regardless of your response, make sure to select «Don’t show this message again», then it won’t block future automated launches of MSWord.
-
I was able to get around this error by opening the program (MS Project 2013 in my case) as the local system account (since that is the user of the service) and going through the default program setting dialogs and then closing it. To open it as the local system account I used technet.microsoft.com/en-us/sysinternals/bb897553 and opened a command prompt (as administrator) and then issued this command:
psexec -s -i "C:Program Files (x86)Microsoft OfficerootOffice15WINPROJ.EXE"
The executable will be whatever program is the problem. -
Please clean up your suggestion; it’s really hard to follow what you’re saying.
-
Sadly this does not apply to all cases. My Excel is registered and I’m getting the said error.
-
I have had a similar issue using an Excel.Sheets collection in an asynchronous method. But the issue has not appeared always but rather nondeterministically. After changing the method into a synchronous approach, the problem has not appeared anymore.
Recents
- Remove From My Forums
-
Question
-
User is experiencing this error: ‘OLE Error: Call was rejected by callee’ when trying to export a large report to Excel.
He is using Proclarity Web Professional 6.0.149.501. Our Proclarity databases are SQL2000.
What can be causing this error?
All replies
-
In past cases we’ve seen the OLE errors when exporting large datasets from ProClarity to Excel. 37,000 to 50,000 rows is usually the point that errors start appears. This is due to the fact that this portion of the program was not designed for exports larger than this. Often times we recommend to customers who want to use ProClarity to export large data sets to ignore the errors and wait until the export completes.
Also, ProClarity is an analytics tool and not designed for large reporting tasks such as this. SSRS, however, is for reporting so creating a report in SSRS and even adding a cube action for that report so it appears in ProClarity would probably be a more efficient approach to reaching a reasonable exporting system.
ProClarity 6.3.2210 builds and later have support for Excel 2007 export row and column limitations. Testing documents show that we support the export of >65k rows and >256 columns with this software. However, there may still be a performance issue due to the reporting nature of this type of query.
-Joey
-
Does the export continue even with the popup error message box on the screen? If they click OK on the message box, does the export still continue?
-
Hi Liz,
In my experience yes the export usually continues after an OLE error appears. I’ve seen exports of up to 700,000 rows taking place over 5 hrs. The main point is anything past 50,000 rows is probably best for reporting software like SSRS. For the specific error of «Call was rejected by callee» — check to make sure there isn’t an active cell in Excel at the time of export. If there is an active cell that error will appear and the export will stop. The only workaround is to make sure there isn’t an active cell at the time of export.
hth,
Sean
-
Sean,
Not sure what you mean by an active cell? I have users experiencing the same issue as above and the export does not continue or returns a blank sheet.
Thanks,
Frank
-
An active cell would be a data cell where the cursor is blinking (as when typing text). Are there any other error messages like «cannot find file *.xls» that the end users are seeing?
Microsoft ProClarity | This posting is provided «AS IS» with no warranties, and confers no rights.