Sửa lỗi you must have valid objects selected năm 2024

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Object variable not set (Error 91)

  • Article
  • 09/13/2021

In this article

There are two steps to creating an . First you must declare the object variable. Then you must assign a valid reference to the object variable using the Set statement.

Similarly, a With...End With block must be initialized by executing the With statement entry point. This error has the following causes and solutions:

  • You attempted to use an object variable that isn't yet referencing a valid object.

    Specify or respecify a reference for the object variable. For example, if the Set statement is omitted in the following code, an error would be generated on the reference to MyObject:

    Dim MyObject As Object ' Create object variable. Set MyObject = Sheets(1) ' Create valid object reference. MyCount = MyObject.Count ' Assign Count value to MyCount.

  • You attempted to use an object variable that has been set to Nothing.

    Set MyObject = Nothing ' Release the object. MyCount = MyObject.Count ' Make a reference to a released object.

    Respecify a reference for the object variable. For example, use a new Set statement to set a new reference to the object.
  • The object is a valid object, but it wasn't set because the in which it is described hasn't been selected in the Add References dialog box. Select the object library in the Add References dialog box.
  • The target of a GoTo statement is inside a With block. Don't jump into a With block. Make sure the block is initialized by executing the With statement entry point.
  • You specified a line inside a With block when you chose the Set Next Statement command. The With block must be initialized by executing the With statement.

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).

Note

Interested in developing solutions that extend the Office experience across multiple platforms? Check out the new Office Add-ins model. Office Add-ins have a small footprint compared to VSTO Add-ins and solutions, and you can build them by using almost any web programming technology, such as HTML5, JavaScript, CSS3, and XML.

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.

When using Render Select, if you forget to include any objects, you receive this error message. Unfortunately, when we submit these jobs to our render farm, they just sit there on the job idle showing this message for an infinite amount of time when they could be rendering another scene. Would it be possible to somehow get around this by making it a more severe error so that backburner/ renderpal shows us an error message and skips the chunk?

I know it's my fault for not checking the scene, but when you're working through many, many scenes - things like this can be missed!