EnhancedTextWriter COM Library

Aug 22, 2024 · 1 min read
projects

EnhancedTextWriterCOM shows how to extend Microsoft Office with .NET: a C# class library is exposed as a COM object, registered with regasm, and then called from VBA inside a Word document.

What’s in the repository

  • EnhancedTextWriterLib (C#): the COM-visible class with a SaveToFile method that writes text from a VBA form to disk.
  • EnhancedTextWriter.docm: a macro-enabled Word document with a form that calls the COM object.
  • VBA/EnhancedTextWriterVBA.bas: the VBA module demonstrating both binding styles.

Early vs. late binding

  • Early binding references the type library directly, giving IntelliSense and compile-time type checking.
  • Late binding creates the object at runtime with CreateObject, trading tooling support for deployment flexibility.

The step-by-step walkthrough, including project settings, assembly signing, and registration troubleshooting, is in the tutorial on this site.

Scott Miner
Authors
Quantitative Analyst & Python/.NET Engineer
Quantitative analyst and .NET/Python engineer at Onward Energy in Denver. I build forecasting models, market-data platforms, and the MLOps and CI/CD that keep them honest, backed by an M.S. in Data Analytics (AI & ML, 4.0 GPA) and a decade of SQL Server, analytics, and full-stack work.