アプリ版:「スタンプのみでお礼する」機能のリリースについて

C#でプログラミングをしています。

Excelで、太枠で選択されたセルのセル参照を表示させたいのですが出来ません。
---------
string t;
Excel.Application oApplication = null;
Excel.Range oRange = null;

oApplication = new Excel.Application();
oRange = oApplication.ActiveCell;

t = oRange.get_Address(Type.Missing, Type.Missing, Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing);
MessageBox.Show(t);
---------
oRangeがnullのままなのですがなぜでしょうか??

A 回答 (1件)

質問に書かれたコードの他に既存のExcelファイルを開くコードがあると思うのですが、それが失敗しているのでは。



下の@ITの記事などを見てusingとExcelファイルを開くコードを追加したらセルアドレスが表示されました。

http://www.atmarkit.co.jp/fdotnet/dotnettips/717 …

Vista Ultimate SP1 + C# 2008 Express Edition + Excel 2007 で試しました。
    • good
    • 0
この回答へのお礼

Excel.Workbook oWBook;
oWBook = (Excel.Workbook)(oApplication.Workbooks.Open(
@"C:Bookwork.xlsm", // オープンするExcelファイル名
Type.Missing, // (省略可能)UpdateLinks (0 / 1 / 2 / 3)
Type.Missing, // (省略可能)ReadOnly (True / False )
Type.Missing, // (省略可能)Format
// 1:タブ / 2:カンマ (,) / 3:スペース / 4:セミコロン (;)
// 5:なし / 6:引数 Delimiterで指定された文字
Type.Missing, // (省略可能)Password
Type.Missing, // (省略可能)WriteResPassword
Type.Missing, // (省略可能)IgnoreReadOnlyRecommended
Type.Missing, // (省略可能)Origin
Type.Missing, // (省略可能)Delimiter
Type.Missing, // (省略可能)Editable
Type.Missing, // (省略可能)Notify
Type.Missing, // (省略可能)Converter
Type.Missing, // (省略可能)AddToMru
Type.Missing, // (省略可能)Local
Type.Missing // (省略可能)CorruptLoad
));
を追加したらできました!
ありがとうございました^^

お礼日時:2009/01/06 14:11

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!