The Nameless City

何故か製薬やSAS関連のブログ、の予定。

HRESULT系のエラーがSASに絡むと大変だよなあという。

頭を悩ませて来た問題ではあるんだけど。
混ざって来てたから一緒の問題だと思い込んでたけど、違うわ・・・・・・


HRESULT 800ac472 from set operations in Excel

Yes, you are getting the VBA_E_IGNORE error that Excel will return when you try to invoke the object model when the property browser is suspended.

HRESULT Codes in Excel interop in C# - Stack Overflow

HRESULT codes that start with 0x800A are internal errors in the application that you are interoperating with. The last 4 digits are the hex code of the internal error. So in your case that's 0xC472 == "Excel error 50290". That gives your user a hundred thousand Google hits. "The file used has this or that problem" gives your user no Google hits, Microsoft does not maintain a mapping of internal error codes to error descriptions and Google doesn't maintain a list of your error descriptions. Use Marshal.GetHRForException() – Hans Passant Jun 5 '14 at 21:04

へえ。

https://support.microsoft.com/ja-jp/kb/820595

オートメーション サーバーとなっている Excel 2002 は、オートメーションのメソッドやプロパティの設定を実行しようとすると、ユーザーの入力処理など Excel が他の処理を行っているかどうか確認するようになりました。ActiveX コントロールなどの外部コンポーネントとの通信の間でイベントを発生させるプログラムの場合、一時的に Excel の準備ができていない状態になることがあり、このときにオートメーションの通信を行うと、Excel は実行時エラーを返します。

Ready プロパティを使用し、アプリケーションの準備ができている場合にだけ処理を実行します。Ready プロパティは Excel 2002 で新しく追加されたプロパティです。

これらの情報は古いが、内部でおそらく同様の状況になってそうだ。


ともかく。
SASのAMOでこの手の問題が発生していて、
Excel2010で確認してみたが、プロパティはある。
ただ、まあ、これに対応しているかどうかは、VSTOアドインの中身をリバースでもせんと分からんから無理だなあ。対応していても、さてReadyに対応してりゃこのエラー吐かなくなるかは分からないし。
HRESULT 800ac472
"ExcelのExceptionなので対応が無理"という訳ではなかろうちうのは普通に思う所ではあるが、
ここらへんの情報を煮詰めて問い詰めないと、多分対応しないんだろうなあ。はあ。