Runtime Error 91, also known as “Object variable or With block variable not set,” occurs when the object variable is used without properly setting or initializing it. This commonly known error perplexes users for all the right reasons and casts a shadow of uncertainty over the smooth operation.
As a result, it disrupts the normal operation of software, including MS Office and custom-built applications using Visual Basic. Users generally encounter this issue while working with objects, variables, and object-oriented programming.
Let us investigate the intricacies of this error and uncover the hidden mechanisms that govern the seamless functioning of digital tools.
What Causes The Runtime Error 91?
Now, know the causes of the Runtime Error 91 and diagnose and fix the error once you encounter it:
- Uninitialized object variable
- Null object reference
- Missing object library reference
Are you wondering How To Fix An Encoding Error In Microsoft Word? Read through this detailed guide.
How To Fix The Runtime Error 91?
To resolve runtime runtime error 91, these are the recommended fixes:
1. Try Starting Word in Safe Mode
Starting Word in Safe Mode will isolate the program from potential conflicts or add-ins that may be responsible for the error. Launching it in Safe Mode will load with minimal functionalities and settings that will no longer trigger the runtime error.
To do that, follow the steps:
- Press Windows + R, type “winword /safe” in the Run dialogue box, and press Enter.
- Doing this will open Word in Safe Mode.
- If you can work here, then add-ins are responsible for the issue.
- Go to the next solution to turn off add-ins.
2. Disable Add-Ins
Disabling add-ins will prevent the corrupted or problematic add-ins from interfering with the regular operation of the application.
Doing this will allow you to deal with the issue and prevent it from causing further problems. It is a proactive approach to help avoid runtime error 91, ensuring a smooth and efficient user experience.
To turn off add-ins, follow the steps:
- Press the Windows + R to open Run Utility.
- Type winword.exe/a in the Run command box and press Enter.
- This should open Word in Safe Mode without Plugins.
- As shown previously, you can also use Winword/safe to start Word in Safe Mode.
- If Word starts in safe mode, click on File button, then Options.
- Choose Add-ins, then click on the Go button beside the Manage tab.
- From the dialog box, uncheck the checkboxes following the add-ins.
- This will turn off the add-ins.
- For saving the changes, click on the OK button.
3. Repair or Reset Office Application
Repairing an application will fix issues without deleting your data, while resetting it will delete all app data, including preferences and sign-in details.
Take a look at the steps below to resolve the issue within the application, thereby ensuring smooth functionality and improved performance :
- Press the Windows + I buttons on your keyboard to Open Settings.
- Select Apps from the given options and scroll down to find Office from the Installed Apps.
- Click on the three dots menu and choose Advanced options.
- Scroll down and select Repair. When you decide to Repair Office, the app’s data won’t be affected.
- If this does not work, then select the Reset option. If you choose the Reset option, the app’s data will get deleted.
- Choose either the Repair or Reset option, and wait for the process to get over.
4. Repair Word From the Control Panel
Go ahead and access the Programs and Features option in the Control Panel and then repair the installed MS Word application. This Repair is known to restore Word’s functionality and resolve issues that may be responsible for a smooth user experience with the application.
Here is how to do so :
- Open the Control Panel using Windows Search.
- Open Programs and Features.
- Right-click on Microsoft Office from the app list.
- Select the Change option.
- Select Quick Repair and click on the Repair option.
- Follow the instructions provided on the screen to complete the entire process.
5. Change DCOMCnfg.exe Settings
If the DCOMCnfg.exe file is corrupted, you may get a “Runtime Error 91: Object variable or with block variable not set” error message.
To fix the issue, you can change its Settings and to do it, follow the steps mentioned below :
- Search DCOMCnfg.exe in the Windows Search bar and hit “Enter.”
- Now, expand the Component Services, then select Computers.
- Right-click on “My Computer” and click on the Properties option.
- Click the “COM Security” tab, and under Access Permissions, click on Edit Limits.
- Select Everyone from the groups and ensure that Local and Remote Access is set to Allow.
6. Run SFC And DISM Scans
Running SFC and DISM scans will address the system file corruption and component store issues that are contributing to the error:
- To do that, type “cmd” in the Windows Search box.
- Select the “Run as administrator” option.
- Copy the following command, paste it into the elevated Command Prompt window, and press “Enter.”
sfc /scannow
Soon, Windows will start scanning and check if that can fix the error or run a DISM scan.
These are the steps of the DISM scan:
- Open an elevated Command Prompt Window and press the Enter key:
- DISM /Online /Cleanup-Image /CheckHealth
After the process, restart your PC and see if the error is fixed.
7. Reinstall Office
Reinstalling Office could help resolve runtime error 91 if corrupted installation files or settings cause it.
Reinstalling it will result in a clean installation and will also help in restoring the proper functioning of the software.
This is how you can do it :
- Press Windows + R to open the Run utility.
- Enter appwiz. cpl in the Run dialog box.
- Press the Enter key to run the command.
- Find Microsoft Office from the installed apps.
- Right-click on it and select the Uninstall option.
- Follow the onscreen instructions to finish the entire process.
Best Practices To Prevent Runtime Errors In Programming
Below are some best practices to prevent runtime runtime errors in programming:
- Check the data type compatibility and range validation
- Implement error handling mechanism
- Plan and outline your algorithm before coding
- Make sure you have clear documentation and effective communication
Frequently Asked Questions (FAQs)
- Does Runtime Error 91 Only Occur In Microsoft Office Applications?
No, it isn’t only limited to MS Office applications.
- Can Runtime Errors Be Caused By Third-party Add-ins Or Plugins?
Yes, problematic or incompatible third-party add-ins or plugins can sometimes trigger runtime error 91.
- Is Runtime Error 91 Exclusive To Only Windows-Based Applications?
No, runtime error 91 isn’t exclusive to Windows-based applications and can occur in any software developed for other OS, such as macOS or Linux.
Wrap Up
As we come to the end of the blog we can now say that understanding the underlying causes of this error and troubleshooting the issue is essential to embrace the challenges.
Write to us in the comment section below if you face any issues while performing the solutions.