Insert / Delete columns in Excel via AutoHotkey

Columns in Excel via AutoHotkeyThis post continues to build on using AutoHotkey via COM to manipulate Excel.  This time I demonstrate how easy it is to use an AutoHotkey function to insert columns, delete columns and set column widths.  All of which are utilizing a simple function after connecting to Excel via AutoHotkey and COM.

Here’s the video demonstrating how to manipulate columns in Excel via AutoHotkey.

Inserting / Deleting columns & setting widths in Excel with AutoHotkey

Here is the code where I demonstrate in the above video how to manipulate columns in Excel via AutoHotkey.  Make sure you connect to the Excel object before calling the functions!

Setting Horizontal and Vertical Excel cell alignment with AutoHotkey

Excel cell alignment with AutoHotkey

Excel cell alignment with AutoHotkey

I love how easy it is to use AutoHotkey to set Excel formatting.   The below AutoHotkey syntax and video show how easy it is to set both vertical and horizontal alignment within Excel.  It also introduces the concepts of Excel Constants.

Video walking through Excel cell alignment with AutoHotkey

Setting Horizontal and Vertical Excel cell alignment with AutoHotkey

 

AutoHotkey and Excel Object model: Application, Workbook, Worksheet

While using AutoHotkey to connect to Excel is “easy”, it is also easy to be trying to use call a function to the wrong Excel object.  In this video we discuss the below diagram and explain how to use AutoHotkey and Excel Object model.

autohotkey-and-excel-object-model

Here is the function for specifying which Excel object you want to connect to

Video walking through AutoHotkey and Excel Object model

AutoHotkey and Excel Objects-Application, Workbook, Worksheet

Create / Connect to Excel with AutoHotkey via COM

excel-with-autohotkey

Automating Excel with AutoHotkey is pretty easy however first connecting with the Excel object can be a bit confusing.

This video walks through both connecting with a running Excel application and creating a new one.  It also walks you through how to set the object visible (and use the Task Manager to see if it exists)

Here is the code reviewed in the video:

Creating & Connecting to Excel with AutoHotkey via COM

Creating & Connecting to Excel with AutoHotkey