Macro Run-time Error '5941'



raymond
07-10-2005, 12:04 AM
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!

Jay Freedman
07-10-2005, 12:04 AM
raymond wrote:
> 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.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

raymond
07-10-2005, 12:04 AM
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

"Jay Freedman" <jay.freedman@verizon.net> wrote in message
news:%2392LEBcdFHA.3396@TK2MSFTNGP10.phx.gbl...
> raymond wrote:
>> 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.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
>
>

raymond
07-10-2005, 12:04 AM
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!


"raymond" <Raymond@drexel.edu> wrote in message
news:11bp2qh7qk1thfa@corp.supernews.com...
> 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
>
> "Jay Freedman" <jay.freedman@verizon.net> wrote in message
> news:%2392LEBcdFHA.3396@TK2MSFTNGP10.phx.gbl...
>> raymond wrote:
>>> 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.
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org
>>
>>
>
>

Jay Freedman
07-10-2005, 12:04 AM
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.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

On Fri, 24 Jun 2005 14:41:25 -0800, "raymond" <Raymond@drexel.edu>
wrote:

>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!
>
>
>"raymond" <Raymond@drexel.edu> wrote in message
>news:11bp2qh7qk1thfa@corp.supernews.com...
>> 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
>>
>> "Jay Freedman" <jay.freedman@verizon.net> wrote in message
>> news:%2392LEBcdFHA.3396@TK2MSFTNGP10.phx.gbl...
>>> raymond wrote:
>>>> 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.
>>>
>>> --
>>> Regards,
>>> Jay Freedman
>>> Microsoft Word MVP FAQ: http://word.mvps.org
>>>
>>>
>>
>>
>


Macro Run-time Error '5941'