Lỗi microsoft visual basic runtime 91 trong excel 2010

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.

Lỗi Run time error do nguyên nhân sau: Có Virus trong máy tính, Bộ nhớ thiếu, Xung đột với phần mềm khác, Phần mềm không tương thích…

Lỗi microsoft visual basic runtime 91 trong excel 2010

Nguyên nhân gây lỗi Run time error

– Có Virus trong máy tính – Bộ nhớ thiếu – Xung đột với phần mềm khác – Phiên bản phần mềm không tương thích – Không có máy in mặc định default trong máy tính của bạn …

Cách sửa lỗi Run time error ‘9’ Subscript out of range trong windows

Bạn thử 1 trong các cách sau, cách nào được thì không làm các cách còn lại nữa

Cách 1: Vào Run gõ lệnh sau

regsvr32 scrrun.dll

Click nút OK là xong.

Cách 2: Thiết lập lại thông số trong Regional and Languages

Vào Control Panel, chọn Regional and Language Options

Trong thẻ Formats ta thiết lập như sau:

– Format: Vietnamese (Vietnam)

– Short date: dd/MM/yyyy

– Long date: dd MMMM yyyy

– Khởi động lại máy tính

Cách 3: Cài một máy in default vào máy

Start > Control Panel > Printers and Faxes (hoặc Devices and Printers) Kích Add a Printer và làm theo đồ thuật để thêm 1 máy in vào (có thể cài máy in ảo). Hoặc là chọn 1 máy in nào đó rồi kích phải chọn Set default.

Cách 4: Kiểm tra Virus và phần mềm Virus

– Scan để đảm bảo máy tính không bị virus. – Có thể một phần mềm Virus đã ngăn không cho cài thư viện dll của Dự toán GXD nên khi phần mềm chạy bị thiếu file đó và báo lỗi Run-time. Nếu trong máy tính cài phần mềm AntiVir hoặc Kapersky thì tạm thời gỡ phần mềm này ra hoặc tắt chức năng bảo vệ tự động đi. Sau đó cài Dự toán GXD, chạy thử phần mềm dự toán OK rồi hãy cài lại hoặc active lại phần mềm virus.

Cách 5: Scan Registry trong máy tính

Một số máy tính do cài đặt và tháo gỡ nhiều phần mềm khác rồi, các phần mềm đó có thể để lại rác hoặc lỗi trong Registry của Win làm ảnh hưởng hoạt động những phần mềm còn lại trong máy tính. Bạn thử tải và cài một phần mềm quét và làm sạch Registry cài và máy tính rồi chạy. Sau đó thử cài, chạy lại Dự toán GXD.

Cách 6: Tải bản Microsoft Visual C++ mới về cài đè vào

Cách 7: Upate Window

– Tùy vào từng phiên bản Window mà cách Update khác nhau.

Cách 8: Cài lại Win

Trường hợp xấu nhất là do Windows bị lỗi, phải cài lại Win

Xem thêm: Hướng dẫn nộp tờ khai thuế qua mạng, sửa lỗi HTKK