Call function from DLL?

Depends on what type of DLL. Is this built in .NET ? if it is unmanaged code then here is an example otherwise the Answer from Rob will work. Unmanaged C++ dll example: using System; using System.Runtime.InteropServices; You may need to use DllImport [DllImport(@”C:\Cadence\SPB_16.5\tools\bin\mpsc.dll”)] static extern void mpscExit(); or [DllImport(“user32.dll”, CharSet = CharSet.Unicode)] public static …

Read more

Excel Interop – Add a new worksheet after all of the others

Looking at the documentation here http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet.move(v=vs.80).aspx, it indicates that the ‘after’ object isn’t a numerical position; it’s the object representing the sheet you want to position your sheet after. The code should probably be something like (untested): workbook.Sheets.Add(After: workbook.Sheets[workbook.Sheets.Count]);

A Simple C# DLL – how do I call it from Excel, Access, VBA, VB6?

You can’t access a static member via COM interop. In fact your code doesn’t even compile, the method should be in a class. Here is how you can do it: [InterfaceType(ComInterfaceType.InterfaceIsDual)] [Guid(“01A31113-9353-44cc-A1F4-C6F1210E4B30”)] //Allocate your own GUID public interface _Test { string HelloWorld { get; } } [ClassInterface(ClassInterfaceType.None)] [Guid(“E2F07CD4-CE73-4102-B35D-119362624C47”)] //Allocate your own GUID [ProgId(“TestDll.Test”)] public class …

Read more

Handling Null Values in F#

For some reason (I haven’t yet investigated why) not (obj.ReferenceEquals(value, null)) performs much better than value <> null. I write a lot of F# code that is used from C#, so I keep an “interop” module around to ease dealing with null. Also, if you’d rather have your “normal” case first when pattern matching, you …

Read more