Input, control and automation

Thursday, 17 September 2015

VBA: 32,767 Leagues Under the Sea

04:38 Posted by Roxton No comments
A few weeks ago I attended a friend's stag-do in Dublin. He, I, and almost everyone else there had met while studying (in my case "attending" or "appearing on a register" might be a better description) at Imperial College, and we are all now techies of varying degrees of hardness (the groom does webby, 2.0-esque stuff, but we try to be kind). During a conversation I mentioned that as I was doing...

Tuesday, 15 September 2015

Arrays in VBA

06:02 Posted by Roxton , No comments
Judged entirely on its own merits, the implementation of arrays in VBA is neither significantly better nor worse than in most other scripting languages. They are, however, idioscyncratic in ways that seem specifically designed to confuse visitors - rather like the Paris Metro. Flicking back and forth between C#, C++, Java and VBA, I often catch myself using square brackets instead of parentheses...

Tuesday, 8 September 2015

VBA: Test if style exists in Word document

06:51 Posted by Roxton , , 3 comments
Frustratingly, there isn't a native function for testing whether or not a particular style exists in a Word document or template. The most direct and obvious way to work this out is to loop through all the styles in the document, thus: Dim style As Word.Style For Each style In ActiveDocument.Styles If style = "style_to_test" Then Debug.Print "style_to_test exists in this document" ...