This project has moved and is read-only. For the latest updates, please go here.

The Problem:

In some situations its possible the Office application reject your call, in this case you got a RPC_E_CALL_REJECTED exception. The reasons for a reject can be different. The office application is busy or its now allowed in current state. You may know this behaviour from MS Excel. Any programmatically access is prohibited when the user create or edit a cell formula.

The most common problem is you dont know the application is busy or not. A common solution is a delay and retry the call at hand. A lot of topics in the developer communitys shows you this way.(stackoverflow example

The Solution:

A message filter is a manager for rejected calls (RPC_E_CALL_REJECTED) and gives you more control for these situation. A technical instruction can be found
here. The message filter can retry the rejected operation for you. You dont have to change your existing code and your code is more safety. NetOffice contains a ready-to-use MessageFilter implementation. 

Overview - NetOffice.Settings.MessageFilter

Property Description Default
Enabled enable or disable the messagefilter false
RetryMode specify the retry behaviour Immediately
LogMode specify the log behaviour. None

Example in Visual Basic

NetOffice.Settings.MessageFilter.Enabled = True

' set few milliseconds delay for retry 
NetOffice.Settings.MessageFilter.RetryMode = NetOffice.RetryMessageFilterMode.Delayed


Example in C# 

NetOffice.Settings.MessageFilter.Enabled = true;

// set few milliseconds delay for retry 
NetOffice.Settings.MessageFilter.RetryMode = NetOffice.RetryMessageFilterMode.Delayed;

Last edited Oct 6, 2012 at 11:08 PM by SebastianDotNet, version 4


No comments yet.