Calling .Net Assembly from VBA

Stuck in VBA?  You don’t have to be.  You can move all your business logic code from VBA to a .Net assembly.  It’s easier than you might think and this post will show you how. First you need to create a new Class Library project and below is the basic structure of a COM-callable wrapper …

Continue reading Calling .Net Assembly from VBA

Advertisements

Access: Type Mismatch Run-time Error After Converting to ACCDB Format

You might receive a Run-time error '13': Type mismatch after converting a Microsoft Access database from .mdb to .accdb format.  The solution might be as easy as removing the reference to the ADO object library, if you are not using it. Open the Access database in question. Open the Visual Basic Editor (VBE) by pressing ALT+F11. …

Continue reading Access: Type Mismatch Run-time Error After Converting to ACCDB Format

Access VBA: How To Call A Windows Form Application with Arguments

To call a Windows Form application (*.exe) with arguments in VBA, you use the Shell() function. Shell "C:\Dev\SampleWinFormWithArgs.exe arg1", vbNormalFocus   Inside the Windows Form application, you get the command line arguments using Environment.GetCommandLineArgs(). string[] args = Environment.GetCommandLineArgs(); // you can call GetCommandLineArgs() anytime, anywhere foreach(string arg in args) { // do stuff // note …

Continue reading Access VBA: How To Call A Windows Form Application with Arguments

SQL Server: How to Linked Server an Access Database

Below is the script to create a linked server to an Access database: EXEC master.dbo.sp_addlinkedserver @server = N'MyLinkedServerAccessDB', @srvproduct = N'Access', @provider = N'Microsoft.Jet.OLEDB.4.0', @datasrc = N'C:\MyAccessDB.mdb'   Plus you also need to create the linked server login.  What’s important to note here is that the password for the admin account in the Access database …

Continue reading SQL Server: How to Linked Server an Access Database