How to get the current open documents in Excel usi

2019-03-31 00:45发布

All I need is to get the list of currently open documents in the currently open instance of Microsoft Excel.

But I don't know Excel terminology to know if these documents are called workbooks, or sheets, or windows, etc.

Any ideas

2条回答
家丑人穷心不美
2楼-- · 2019-03-31 01:25

Found it (link).

//Excel Application Object
Microsoft.Office.Interop.Excel.Application oExcelApp;

this.Activate ( );

//Get reference to Excel.Application from the ROT.
oExcelApp = ( Microsoft.Office.Interop.Excel.Application ) System.Runtime.InteropServices.Marshal.GetActiveObject ( "Excel.Application" );

//Display the name of the object.
MessageBox.Show ( oExcelApp.ActiveWorkbook.FullName );

//Release the reference.
oExcelApp = null;
查看更多
Deceive 欺骗
3楼-- · 2019-03-31 01:49

You're looking for the Workbooks property.

查看更多
登录 后发表回答