Tag: 办公自动化

从C#调用某些Excel VBA宏时出错

我一直在努力和搜索这个问题无济于事…我有一些测试宏在从Excel运行时工作得很好但是从C#调用时失败或不工作,使用互操作… 我正在使用MS Visual Studio 2012(在64位Windows 7上)创建一个控制台应用程序,它将调用用Excel 2007编写的VBA宏TestMacro()。 下面是调用宏的C#代码:(我基本上复制了在这里完成的操作从Visual C#.NET使用自动化运行Office宏 ) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Configuration; using System.Reflection; using Excel = Microsoft.Office.Interop.Excel; using Microsoft.Office.Core; namespace C#_Macro_Wrapper { class Program { static void Main(string[] args) { RunVBATest(); } public static void RunVBATest() { System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture; System.Threading.Thread.CurrentThread.CurrentCulture = new […]