Updated December 2023: Stop getting error messages and slow down your system with our optimization tool. Get it now at this link
Have you encountered the Microsoft Visual Basic error “Runtime error ’91’: Object variable or With block variable not set” when you open a SOLIDWORKS file? Or when you create a new SOLIDWORKS macro and see that message appear when you run it?
Fortunately for you, this is a very common VB error, and it’s not very difficult to determine where the problem lies.
What causes runtime errors 91?
The reason why the pop-up window with the message “Runtime Error 91: Object variable or with block variable not set” appears is because the DCOMCnfg.exe file may be corrupted. The DCOMCnfg.exe file is commonly used to configure permissions and set security settings on a system. If there is a problem with this file, your system will not be able to load the files needed to start up, and a runtime error 91 will be displayed.
To fix this runtime error, we have found some very effective methods. We will present them one by one, with a detailed description of the steps. You can apply these methods and try to solve the problem yourself.
How to fix runtime error 91?
The runtime error 91 may be related to the .NET Framework and Visual Basic, for which updates are applied through Windows Updates. Therefore, make sure that your Windows is up to date:
- Right-click the Start button and select Settings.
- Select Update and Security
- Click Check for updates.
- Wait for Windows to download and install any necessary updates.
- Restart your computer
Reinstall the problem application
- Type Control Panel in the Windows search box and press Enter.
- Go to Programs -> Uninstall Application
- Select the application from the list, right-click and select Uninstall.
- Then reinstall the application.
Specify that DCOMCnfg.exe can be run by “anyone”
- Type DCOMCnfg.exe in the Windows search box and press Enter.
- In the Component Services window, expand the following items: Component Services -> Computer -> My Computer
- Right-click My Computer and select Properties
- Select the COM Security tab and under Access Permissions, select Edit Limits.
- Select Everyone in Groups and make sure that Local Access and Remote Access are set to Allow.
Scan your computer for malware
- Click the arrow on the taskbar and double-click the Windows Security icon.
- Select Protect Against Viruses and Threats.
- Select the scan options under the Quick Scan button
- Select the Full Scan option and click the Scan Now button.
Expert Tip: This repair tool scans the repositories and replaces corrupt or missing files if none of these methods have worked. It works well in most cases where the problem is due to system corruption. This tool will also optimize your system to maximize performance. It can be downloaded by Clicking Here
Frequently Asked Questions
- In Windows search, type Control Panel and press Enter.
- Go to Programs -> Uninstall a program.
- Select the application in the list, right-click on it, and select Uninstall Reinstall the problem application.
- Then reinstall the application and see if that fixes error 91.
VBA Runtime Error 91 is a common error that occurs during VBA development. This error occurs when you try to use an object variable (i.e., an "object" type variable) that is not (correctly) assigned an object.
Runtime errors are errors that occur after the code has been compiled and executed. This is code that looks correct because it has no syntax errors, but cannot be executed. For example, you might write a line of code to open a file correctly.