Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Macro Run-time Error '5941'
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! |
#2
|
|||
|
|||
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 |
#3
|
|||
|
|||
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" wrote in message ... 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 |
#4
|
|||
|
|||
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" wrote in message ... 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" wrote in message ... 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 |
#5
|
|||
|
|||
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" 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" wrote in message ... 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" wrote in message ... 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 |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Table in a Form | Tables | |||
Macro Button Won't Stay on Toolbar | Microsoft Word Help | |||
Possible bug when recording a Word Macro | Microsoft Word Help | |||
Running document macro from server | New Users | |||
2000 to 2002 macro and "Could not open macro storage" | Mailmerge |