Subscript problem

R

Rhino

I'm just getting back into Word Macros after a long absence in which I feel
like I've forgotten almost everything.

My macros worked perfectly in Word 2002 but I've upgraded to Word 2007 and
now I'm having a problem or two.

The one that concerns me most right now is a subscript error. This is the
macro that is giving me trouble:

==================
Public Function exportMacros(exportedMacrosFile As String) As Long

If doesPathExist(exportedMacrosFile) = False Then
MsgBox "The path to which you want to write the macros, " &
exportedMacrosFile & ", does not exist. " & vbCrLf & "The macro must abort
without exporting."
exportMacros = 1
Exit Function
End If

'Export the macros to the designated file. Inform the user where they were
written.
Application.VBE.ActiveVBProject.VBComponents(2).Export exportedMacrosFile

'At this point, the export was successful.
MsgBox "Your macros were exported to " & exportedMacrosFile & "."
exportMacros = 0

End Function
==================

I get the subscript error on the line that says:
Application.VBE.ActiveVBProject.VBComponents(2).Export exportedMacrosFile.

The only subscript I can see in that line is the '2' but I'm darned if I can
remember where to find the documentation on the API (or whatever it is
called for Word Macros) so that I can look up what this code means.
Embarassing? You bet! I wrote this so you'd think I'd remember more about
it! But it's been four long years since I wrote my macros - with some help
from the Microsoft newsgroups - and I remember very little of the
experience....

If anyone can point me toward the documentation and/or clue me in about what
I'm doing wrong, I'd appreciate it.

I'm assuming that there was some kind of change in the API between Word 2002
and 2007 that is invalidating my old code. I'm hoping that there's not too
much else wrong in my macros....
 

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