0

我制作了一个小宏并将其保存在我的个人宏工作簿中。用新的 Excel 工作簿对其进行了测试,它可以工作(我可以在不同的工作簿中看到它)。但是,当我以编程方式生成新的 Excel 工作簿时,我看不到宏。有没有办法解决这个问题并在该工作簿中也可以看到宏?

Microsoft.Office.Interop.Excel.Application exc = new Microsoft.Office.Interop.Excel.Application();
exc.Visible = true;
exc.Workbooks.Add();
ExcelWorksheet = exc.ActiveSheet;

这是我用来生成 excel 工作簿的代码。

4

1 回答 1

0
       var excelApp1 = new Excel.Application();
        // Make the object visible.
        excelApp1.Visible = true;

        // Create a new, empty workbook and add it to the collection returned 
        // by property Workbooks. The new workbook becomes the active workbook.
        // Add has an optional parameter for specifying a praticular template. 
        // Because no argument is sent in this example, Add creates a new workbook. 
        excelApp1.Workbooks.Add();

        // This example uses a single workSheet. 
        Excel._Worksheet workSheet1 = excelApp1.ActiveSheet;
于 2013-12-05T22:38:49.863 回答