Create metafile from icon and label

Going further on the Windows Metafile problematic from a previous post, I’ve created a sample code for illustration a pretty useful functionality from OLE. What the OLE function implemented here does is to generate a metafile with the icon and label for a specific file: The way to do this is: 1. Call SHGetFileInfo to…


DLL Injection

In a previous post, I was discussing the idea of adding more events to Excel by adding a window hook. Under the hood, the idea is that we can load a DLL in the Excel process simply by transforming that DLL into a COM add-in, which is automatically loaded by Excel. This post covers the…


Extra Events for Excel

As a developer of Automation solutions for Microsoft Office one might feel the need of some extra events. Quoting from the MSDN VBA Object Model reference, here is the list of events from the Excel.Application object:  AfterCalculate Event CalculationDone Event NewWorkbook Event SheetActivate Event SheetBeforeDoubleClick Event SheetBeforeRightClick Event SheetCalculate Event SheetChange Event SheetDeactivate Event SheetFollowHyperlink…


EMF+ Untangled

A common belief regarding the EMF format, at least as it appears by browsing technical blog posts, is that this format was never documented by Microsoft and that there are many unknown facts about it. This opinion is wrong, as the format has complete publicly available specifications posted on MSDN. That being said, I do…


OLElsTool – Working with OLE storages

I’m posting here a tool that can be used for viewing and modifying OLE storage. The syntax is as follows: Usage: OLElsTool.exe <File_In> <Options>          -L: list          -X <part> <toFile>: extract part          -M <part> <fromFile>: modify part  Sample usage: say we copy an Excel range and paste it into Word using Paste Special,…


OpenDoc tool unveiled

After the previous blog posts with the OpenDoc tool, I’ve learned that, while this tool can be very helpful, it also raises a lot of questions mainly because it lacks proper documentation. As such, I’ve decided to post the source code giving everybody who is interested the liberty of modifying it to suit their needs….


OpenDoc tool reloaded

In a previous post, I described a tool for editing OpenXML documents from a managed context. I’ve added three more features for some common tasks:  1. Remove a part Syntax:  OpenDoc.exe -r <Input file> <Part> Sample usage scenarios: removing the calculation chain, removing unwanted resources, removing slides, worksheets.  2. Remove all attributes  Syntax: OpenDoc.exe -t…


Working with OpenXML documents

The default format for saving Excel, Word and PowerPoint documents has luckily changed since Office 2007 to the Open XML formats. There is good documentation available for these formats on: MSDN: Introduction to the Office 2007 file formats:   MSDN – sample code: Editing Excel cell values from .NET code:   ECMA: ECMA…


External links in Excel files

Topic   This is a post that contains a tool for analyzing the external links in an Excel Workbook. The tool is intended to provide information regarding the linked workbooks, the cells from a workbook that contain external links, as well as the target worksheets and cells. It will generate an XML report like this:…


Collecting crash dumps

Introduction This post discusses some basic techniques for collecting a crash dump. To test the techniques, we’ll use an application wherein crashes can be triggered intentionally – the CrashMe application from order to make this application crash one needs to press a button from the “Crash Actions” group, e.g. “Stack overflow” or “Division by NULL”….