控制已经打开的Excel

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel; 

namespace ExcelTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            object misValue = System.Reflection.Missing.Value;
            Excel.Application xlApp;
            xlApp = (Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
            //xlApp.ActiveSheet.Pictures.Paste();

            Excel.Workbooks m_objBooks = (Excel.Workbooks)xlApp.Workbooks;

            foreach (object o in m_objBooks)
            {
                string s = ((Excel.Workbook)o).Name;
                MessageBox.Show(s);
                ((Excel.Workbook)o).ActiveSheet.Pictures.Paste().Select();
            }
        }

    }
}
原文地址:https://www.cnblogs.com/wangjixianyun/p/3326565.html