Hello,
I'm trying to get the Excel communicate to Autocad using a DLL but it won't work.
The DLL references fine in Excel, all the COM bits are ticked, the C# project has the references to the correct Autocad libraries (it compiles fine), I can call a simple test function in it but it fails when the Autocad object is called with the error :
Run-time error '-2146233036 (80131534)': Automation error
Help please !
Code:
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Linq;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using CadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.ApplicationServices;
[assembly: CommandClass(typeof(AutocadHandler.MyCommands))]
namespace AutocadHandler
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class MyCommands
{
public static void TestFunction()
{
string strFileName = "C:\\Users\\CORE I7\\Documents\\Drawing2XLS.dwg";
var acDocMgr = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager;
acDocMgr.Open(strFileName, false);
acDocMgr.MdiActiveDocument.Editor.WriteMessage("Hello Excel");
}
}
}