Macro Run-time Error '5941'

R

raymond

Help,

A macro I had been using in Word 2002 is now giving me an error message :
"The requested member of the collection does not exist."

I hope I don't have to re-create this macro...

Any one...?

Thanks!
 
J

Jay Freedman

raymond said:
Help,

A macro I had been using in Word 2002 is now giving me an error
message : "The requested member of the collection does not exist."

I hope I don't have to re-create this macro...

Any one...?

Thanks!

Hi Raymond,

What you've posted isn't quite enough information to be able to help. When
the error occurs, there should be two buttons in the message box, Debug and
Cancel. Click the Debug button, which opens the macro editor. The line where
the error occurred should be highlighted. Paste that line into a reply
message, so we can see which collection the message is talking about.

This sort of error often has more to do with what's in the current document
than with how the macro is constructed. For example, if the macro expects to
work with a table, it may contain a reference to ActiveDocument.Tables(1).
But if the document doesn't contain any tables, that reference will cause
the "does not exist" error message.

A properly written macro should test the document to make sure all the
expected bits are there, and either compensate or quit if they aren't. At
worst your macro needs to have such tests added to the existing code.
 
R

raymond

Thanks for your response!

Here is the highlighted line in the debug dialogue:

With Selection.InlineShapes(1)

This macro was helping me to format, prompt for caption, and update a list
of figures for inserted digital image files. I have it saved in a template.

Thanks for your help...I hope i don't have to record the macro again...

Raymond
 
R

raymond

Let's see, since first using the macro in the template i have reinstalled
Office 2002. How might that be causing a problem?

thanks again!
 
J

Jay Freedman

Hi Raymond,

Reinstalling doesn't have anything to do with it.

The line of code that was highlighted, which was where the error
occurred, is telling VBA to locate the first picture (inline shape,
that is, not a floating shape) within the highlighted text (the
Selection). If the Selection doesn't contain any inline shapes, then
that line causes an error:

The requested member [that is, shape 1] of the collection [the
InlineShapes collection belonging to the Selection] does not
exist.

What I can't tell yet is why the Selection is supposed to contain at
least one inline shape. Are you supposed to select the paragraph (or
other text) containing the shape before you start the macro? Or is the
macro supposed to do a search for shapes in the document? If you can't
tell from reading the macro, post the whole code here and I'll have a
look for you.
 

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