How COM works & How to build a COM visible DLL in C#.Net, call it from VBA and select the proper ClassInterface (AutoDispatch, AutoDual) [part1/2]

  This article is split across two blog posts and this is part #1.. use this link (please be patient :), I am still working on part 2) to go to part #2. When a beginner programmer needs to create a COM visible DLL which will be called from VBA, PowerShell, VBScript or .NET applications, he can find lots of tutorials on how to…

2

VSTO – How to build a setup project which targets x64 bit OS, and add custom Registry Launch Condition that checks if a key is found in the native 64bit registry hive.

A developer that needs to learn all about building and deploying a VSTO 2010 installer project, should carefully review this very nice article: http://msdn.microsoft.com/en-us/library/ff937654.aspx (Deploying a Visual Studio 2010 Tools for Office Solution Using Windows Installer). Starting from the 2010 version, Office applications come in two flavors: x32 bit and x64 bit. If you need to take advantage of the x64 bit…

2

VSTO – .Net code throws ‘System.AccessViolationException’ error when automating the ‘Find’ object in Word (KB 292744 BUG: Automation client receives an error message or crashes when the client calls the Find object in Word)

Sometimes users are running versions of Office which are not fully up-to-date. This might be due to the fact that their local IT department has not tested the new patches and did not approve their company wide distribution, or because the machine is not connected tothe Internet and needs to be manually updated .. or some other reason. At the same…

1

OpenXML & VSTO & VBA – Finding a reliable mechanism for reading the correct value of CharactersWithSpaces ‘extended-properties’ in Word documents [part 2/2].

  This article is split across two blog posts and this is part #2 .. use this link to go to part #1. In part #1 of this article, I demonstrated how words are counted using OpenXML and I warned about the dangers of not getting it done correctly. Here is a short summary of the alternatives we have:    Can we obtain 100% reliable statistics? Method #1:       When Word…


OpenXML & VSTO & VBA – Finding a reliable mechanism for reading the correct value of CharactersWithSpaces ‘extended-properties’ in Word documents [part 1/2].

  This article is split across two blog posts and this is part #1 .. use this link to go to part #2. There are many scenarios when we have to know exactly how many words, pages, paragraphs or characters are found in a certain document:    > we might be developing a tool which searches through files; If we want to add OpenXML files to       its list of…


VSTO & VBA – Improving Excel’s performance when writing data into Sheets by using memory arrays instead of inefficient code loops

In my previous article (VSTO & VBA – How to troubleshoot Excel memory and performance problems caused by inefficient code loops) I wrote about a few common issues which may be encountered when trying to read data from an Excel workbook using COM automation. But after you finished reading it, maybe you asked yourself: What…


VSTO & VBA – How to troubleshoot Excel memory and performance problems caused by inefficient code loops

When working with Excel, a developer sometimes has to search, read or write some cell values and these operations are usually done inside repetitive loop structures. Everything seems to work fast enough for small input files, but once we scale up the design, things can complicate and the end-user experience is severely affected. On the other hand, the developer takes…

5

VBA – How to Find and Edit the Office 2003 legacy CommandBars and menus in Office 2010 (add, remove, edit controls in ‘Menu Commands’ group from Add-Ins tab)

Today I am going to show you how to work with legacy CommandBar controls in Office 2010. Let’s suppose you are in the following scenario: –  you have created a DOT template in Office 2003;-  a couple of macros have been added to the VB project; –  and you also found it convenient to insert a custom menu item to allow end-users / colleagues to easily…

2

VBA – How to programmatically enable access to the VBA object model using macros

    Under certain circumstances a programmer may need to access the VB object model for an Office application and interact with its VBIDE interface (clean-up missing references, back-up macro code … etc).     As described in http://support.microsoft.com/kb/282830, the code may fail with the following errors:   http://support.microsoft.com/kb/282830 Programmatic access to Office VBA project is denied ——————————————————————- From Visual Basic or…

22