ActiveDocument.Convert command in Word 2007

R

Rich W.

I am creating a macro to update all .doc documents from Word 2003 to Word
2007 format, in a user-selected directory.

The macro crashes when I run it; the line it crashes on is:

ActiveDocument.Convert

The error message states "Command not available".

Oddly, when I step through it, the macro will work on the first iteration of
the While/Wend loop. It goes through the "Convert" line fine. (I can look at
the document when the macro is running, due to the fact I'm stepping through
it; I see the command, "Convert" on the Office Button menu.)

Any one have any idea why it can't find the command?

Thanks for any thoughts!
 
K

Klaus Linke

Hi Rich,

An error message isn't really a crash?
If the document is already in 2007 format, you get the error message. It
wouldn't make sense to Convert once more, so the "command isn't available".
You may have noticed it's removed from the Office menu, too.

I don't know a simple way offhand to tell whether the doc already is
converted, but you might simply catch and ignore the run-time error 4605
that you get with an error handler.

Regards,
Klaus
 
R

Rich W.

Thanks Klaus . . .

The interesting thing is that I used the VBA cmd, "On Error Resume Next" and
the "Convert" command worked on documents that it didn't previously work on.
My code now reads:

On Error Resume Next
ActiveDocument.Convert
If (Err.Number = 0) Then
oDoc.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatXMLDocument
Else
Err.Number = 0
numOfErrs = numOfErrs + 1
End If

Well, I'm not really a programmer . . . I don't have the wits for it.

Thanks again,

Rich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top