如何获得在Excel中使用C#当前打开的文件? [英] How to get the current open documents in Excel using C#?

查看:435
本文介绍了如何获得在Excel中使用C#当前打开的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有我需要的是让在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.

任何想法

推荐答案

发现(链接)

//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;

这篇关于如何获得在Excel中使用C#当前打开的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆