回答編集履歴
3
Marshal.BindToMoniker の戻り値を NetOfficeFw.Excel に取り込む
test
CHANGED
@@ -46,7 +46,15 @@
|
|
46
46
|
Excel.Workbook xlBook = workbook as Excel.Workbook;
|
47
47
|
Excel.Application xlApp = xlBook.Application;
|
48
48
|
```
|
49
|
+
インスタンスが無い場合は起動しちゃいます。
|
49
50
|
|
51
|
+
---
|
52
|
+
さらに追記
|
50
53
|
|
54
|
+
Marshal.BindToMoniker の戻り値を NetOfficeFw.Excel に取り込むことも出来ました。
|
51
55
|
|
52
|
-
|
56
|
+
```csharp
|
57
|
+
object book = Marshal.BindToMoniker(@"z:\test.xlsx");
|
58
|
+
Excel.Workbook xlBook = new Excel.Workbook(null, book);
|
59
|
+
Excel.Application xlApp = xlBook.Application;
|
60
|
+
```
|
2
文言
test
CHANGED
@@ -36,7 +36,7 @@
|
|
36
36
|
---
|
37
37
|
### 追記
|
38
38
|
|
39
|
-
既存の Excel を捕まえる手段としては、こんな
|
39
|
+
既存の Excel を捕まえる手段としては、こんなのもあります。
|
40
40
|
こちらは、Microsoft.Office.Interop.Excel を使います。
|
41
41
|
```csharp
|
42
42
|
using Excel = Microsoft.Office.Interop.Excel;
|
1
Marshal.BindToMoniker を使った方法を追加
test
CHANGED
@@ -33,3 +33,20 @@
|
|
33
33
|
|
34
34
|
といったところです。
|
35
35
|
|
36
|
+
---
|
37
|
+
### 追記
|
38
|
+
|
39
|
+
既存の Excel を捕まえる手段としては、こんな手段もあります。
|
40
|
+
こちらは、Microsoft.Office.Interop.Excel を使います。
|
41
|
+
```csharp
|
42
|
+
using Excel = Microsoft.Office.Interop.Excel;
|
43
|
+
using System.Runtime.InteropServices;
|
44
|
+
|
45
|
+
object workbook = Marshal.BindToMoniker(@"z:\test.xlsx");
|
46
|
+
Excel.Workbook xlBook = workbook as Excel.Workbook;
|
47
|
+
Excel.Application xlApp = xlBook.Application;
|
48
|
+
```
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|