Close

September 16, 2014

Using VBA to fix columns in a Word table …

I sent out the preview of the Table Inspector to a few colleagues in work. All seemed to go well. The initial bug found was fixed tout suite but before I sent the update out, someone asked if I could do the same thing with columns as I had with rows.

Seemed easy enough to me, so I added the extra label, text box and spinner. The rows code was mutilated and adapted so it could handle columns (or so I thought) and I added the extra functions and variables to the initialisation routine. This went very well and then I ran the code – I kept getting the same error over and over.

After some reading up from various Word MVPs in numerous forums, I came across a simple bit of text that explained my situation: “Word VBA really hasn’t got a clue about columns. And if you’ve got merged cells, then it really panics!”

So I now need to rethink the loop that goes through each column and change it so it looks at each column, counts the number of cells, sets that as a known range and then go through *each* cell, one-by-one, changing the font and the alignment as the user requested.  What a pain that’s going to be.

Ho hum – that’ll teach me to think I can copy & paste existing code and assume Word VBA knows what I’m trying to do 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: