如何使用C#在Excel中获取当前打开的文档? [英] How to get the current open documents in Excel using C#?
本文介绍了如何使用C#在Excel中获取当前打开的文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所有我需要的是在当前打开的Microsoft Excel实例中获取当前打开的文档的列表。
All I need is to get the list of currently open documents in the currently open instance of Microsoft Excel.
但是我不知道Excel术语是否知道这些文件称为工作簿,工作表或窗口等。
But I don't know Excel terminology to know if these documents are called workbooks, or sheets, or windows, etc.
任何想法
推荐答案
找到它(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;
这篇关于如何使用C#在Excel中获取当前打开的文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文