Feeds:
Posts
Comments

Posts Tagged ‘microsoft office’

T'other day, I knocked together a macro, for a friend, to number the paragraphs in a Microsoft Word document ("manual" rather than hard-coded numbering, that is):

Sub NumberingParagraphs()

    Dim iParagraphs As Integer
    iParagraphs = ActiveDocument.Paragraphs.Count
    
    Selection.HomeKey unit:=wdStory
     
    Do While iCount < iParagraphs
        iCount = iCount + 1
        Selection.TypeText iCount & ": "
        Selection.MoveDown unit:=wdParagraph
    Loop

End Sub

My mate, being curious about, but not having experience of, the workings of such things, took a look and got the basic idea, but couldn't get his head around why the number of loops is seemingly instructed to be one less than the number of paragraphs. Surely, he said, it should be "less than or equal to," rather than "less than." Well, no. His kid got it straight away, and came up with a lovely semi-analogy; which I now share, in hopes that others who've been puzzled by this oft-seen seeming-paradox might see the light. Let's literally (yet figuratively) walk through the macro…

(more…)

Read Full Post »

When I were but a wee nipper, the words "billion" and "trillion" were hardly ever heard, outside of hyperbole, unless one had an interest in astronomy and cosmology. (And even then, we had to be careful in our reading, since the nationality of the author and the editorial policies of their British publisher might make a difference, what with our billion being, until recently, a thousand times larger than the American billion.) These days, "billion" is much more often seen, mostly because of the now-universal adoption of 109 rather than 1012 as the definition of the word, which brings things like world population and national debts into its range; and on the topic of national debts, "trillion" (also shrunken by a factor of one thousand in UK terms) is, distressingly, coming into much more common usage. Which is partly why I found the idea of Microsoft Word's cardtext feature, which converts figures into words—but only up to 999,999—rather less than useful.

(more…)

Read Full Post »

Oops!

I'll begin with a heads-up for John Zande. The first part of this might interest you, John, as I believe it meets a criterion you were asking about a while back.

A kind soul of my acquaintance took it upon herself to beta-test those macros I posted t'other day. Turns out there's a couple of bugs. Both are minor in that they're easily fixed, but one is potentially disastrous in that it causes what I (probably erroneously) think of as a feedback loop. So let's take a look at that first. (I would, in the normal course of things, just edit the post in question and publish a correction-post pointing it out, but as I say, John was asking for an example of this kind of thing a while back, so what the hell; let's expound on it a bit.)

The macro in question is the SelectTheWord macro, and the part that's buggy is this bit: (more…)

Read Full Post »

Some M/S Visual Basic Macros

Hello there Internet. My, but it's been a while.

To the several readers who've sent me mails enquiring after my health, I'm very sorry to have worried you. Twas nought but a clapped-out router taking way too long to replace. I'm replying to emails individually, but my inbox is, well, you can probably guess, so I figured I'd get a post up letting you know I'm hale and hearty. (more…)

Read Full Post »

A couple of years back, when I first discovered macros, I kinda fell a bit in love with them. In particular I was entranced by the Visual Basic Editor packaged with Microsoft Office for the purpose of editing macros, or even writing them from scratch, bypassing the rather naff macro recorder. Long before I had a clue how to even begin to decipher the inner workings of these magical text-spells, let alone edit one myself, I was happily pillaging the internet for complete projects offered up by those sorcerers who do know how to create conjurations with this Clarkian magic. Like any denizen of Arthur C Clarke's magical kingdom, I may not know how to bind the spirits to a purpose, but when a friendly magician gives me the already-imbued Ring Of Invisibility and tells me the magic word, I can use the fruits of her labour with ease. (more…)

Read Full Post »

Ever since I posted an article on Microsoft Word macros, I've had a steady-ish stream of searchers landing on the page, looking for how to enclose paragraphs in <p> … </p> tags using Word's Find/Replace function. I mentioned in passing, in that post, that it can be done but I didn't expand on it. So here's how to do that.

(more…)

Read Full Post »

[In which I moan about the abysmal macro-recorder in M/S Office, and show how to create and edit a macro.]

I finished my previous article with a comment that I've long wanted to have a bit of a whinge about M/S Word's macro recorder. Before I do that, though, I suppose I'd better explain what a macro recorder is. Indeed, what a macro is, given the number of people I've run into who seem have no idea that such things exist. Not to mention the number who start to back away slowly from my apparent geekism if I actually start discussing the ins and outs of them!

(more…)

Read Full Post »