Word: Run-time error 380 fix

April 14, 2011

I love it when I can solve something because someone gives me a tiny clue and a lightbulb goes off in my head!

Holly called me from my client’s office. The automated document properties macro in her Word document wasn’t working. She’d done all the right things — she’d reattached the client’s template containing the macro, then, when that didn’t work, she’d downloaded and reinstalled the template then reattached it again. Nothing was working. She kept getting a Microsoft Visual Basic error message each time she tried to run the macro. The error was: Run-time 380. Could not set value property. Invalid property value.

I’d seen that error message before but had no idea what caused it or how I fixed it last time (I think I just reattached the template). So I got Holly to send me the document to see if there was anything I could see. She was on a tight deadline, so if I didn’t solve the problem in a few minutes, she was going to have to PDF the document as it was and we’d sort out the issue later.

I clicked the Debug option on the error message and got taken to the Visual Basic screens where I saw that the client’s automated document properties form was where the problem lay. But where in that form? There were a lot of fields that we use on that form, and there was no other clue. I looked at the form’s properties and code but nothing jumped out at me. So I called Holly to tell her to go ahead and PDF what she had and I’d look at this some more.

And it was then that she said something about liking having the revision number 1A instead of plain 1 as per the previous choices in the template. And that was the clue! The client’s template only offers revision numbers of A, B, C, etc. and 1, 2, 3, etc. There is no 1A, 1B etc. I looked at the document and sure enough, there was a bookmark and a field both containing 1A. Maybe that was it? I recall helping someone add combined revision numbers to their document ages ago — and I remember telling them it was a one-off and that if they reattached the template, they’d lose those combined revision numbers. What I didn’t know is that it would cause a run-time error!

I opened up Visual Basic, went to the form’s code and changed the existing revision number value from 1 to 1A to match what was in Holly’s document. I saved the changes and re-ran the macro — it ran perfectly!

So that solved the immediate problem, but as it’s likely that this document will be upgraded again, or go to another author using an unmodified template, or that the template may get reattached again, this issue won’t go away until it’s fixed. The fix for this document is to run the macro again, this time selecting one of the whole number revisions to clear the 1A from Holly’s document. Then going back into Visual Basic and changing the form’s code for the revision number from 1A back to 1.

Such a little thing… And when I look again at the error message, it’s correct even though it seems obscure and meaningless. There was an invalid value. But what the error messgae didn’t tell me was exactly where — it only told me it was in the form, not whereabouts in the form. It took Holly’s keen eye to notice the revision number change — and to tell me about it in passing.

It’s very unlikely that if you get this error message in Word that the solution will be the same. But maybe, just maybe, something in here is enough to trigger an ‘Aha!’ moment for you to help you solve your problem.

And I need to document this in case it happens again in one of my client’s documents — as no doubt it will! ;-)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: