Ошибка runtime error 91 object variable or with block variable not set

I have the following code:

Sub AddSources()
    Dim pubPage As Page
    Dim pubShape As Shape
    Dim hprlink As Hyperlink
    Dim origAddress() As String
    Dim exportFileName As String
    exportFileName = "TestResume"
    Dim linkSource As String
    linkSource = "TestSource2"
    Dim hyperLinkText As TextRange



    For Each pubPage In ActiveDocument.Pages
        For Each pubShape In pubPage.Shapes
            If pubShape.Type = pbTextFrame Then
                For Each hprlink In pubShape.TextFrame.TextRange.Hyperlinks
                    If InStr(hprlink.Address, "http://bleaney.ca") > 0 Then
                        hyperLinkText = hprlink.Range
                        origAddress = Split(hprlink.Address, "?source=")
                        hprlink.Address = origAddress(0) + "?source=" + linkSource
                        hprlink.Range = hyperLinkText
                    End If
                Next hprlink
            End If
        Next pubShape
    Next pubPage
    ThisDocument.ExportAsFixedFormat pbFixedFormatTypePDF, "C:" + exportFileName + ".pdf"
End Sub

I am getting the «Object variable or With block variable not set (Error 91)» error on the line with hyperLinkText = hprlink.Range. When I debug I can see that hprlink.Range does have a value. Any thoughts what I’m doing wrong?

Vogel612's user avatar

Vogel612

5,6105 gold badges48 silver badges72 bronze badges

asked Dec 19, 2013 at 21:45

GBleaney's user avatar

4

As I wrote in my comment, the solution to your problem is to write the following:

Set hyperLinkText = hprlink.Range

Set is needed because TextRange is a class, so hyperLinkText is an object; as such, if you want to assign it, you need to make it point to the actual object that you need.

Jean-François Corbett's user avatar

answered Dec 19, 2013 at 21:59

Barranka's user avatar

BarrankaBarranka

20.5k13 gold badges65 silver badges83 bronze badges

I have the following code:

Sub AddSources()
    Dim pubPage As Page
    Dim pubShape As Shape
    Dim hprlink As Hyperlink
    Dim origAddress() As String
    Dim exportFileName As String
    exportFileName = "TestResume"
    Dim linkSource As String
    linkSource = "TestSource2"
    Dim hyperLinkText As TextRange



    For Each pubPage In ActiveDocument.Pages
        For Each pubShape In pubPage.Shapes
            If pubShape.Type = pbTextFrame Then
                For Each hprlink In pubShape.TextFrame.TextRange.Hyperlinks
                    If InStr(hprlink.Address, "http://bleaney.ca") > 0 Then
                        hyperLinkText = hprlink.Range
                        origAddress = Split(hprlink.Address, "?source=")
                        hprlink.Address = origAddress(0) + "?source=" + linkSource
                        hprlink.Range = hyperLinkText
                    End If
                Next hprlink
            End If
        Next pubShape
    Next pubPage
    ThisDocument.ExportAsFixedFormat pbFixedFormatTypePDF, "C:" + exportFileName + ".pdf"
End Sub

I am getting the «Object variable or With block variable not set (Error 91)» error on the line with hyperLinkText = hprlink.Range. When I debug I can see that hprlink.Range does have a value. Any thoughts what I’m doing wrong?

Vogel612's user avatar

Vogel612

5,6105 gold badges48 silver badges72 bronze badges

asked Dec 19, 2013 at 21:45

GBleaney's user avatar

4

As I wrote in my comment, the solution to your problem is to write the following:

Set hyperLinkText = hprlink.Range

Set is needed because TextRange is a class, so hyperLinkText is an object; as such, if you want to assign it, you need to make it point to the actual object that you need.

Jean-François Corbett's user avatar

answered Dec 19, 2013 at 21:59

Barranka's user avatar

BarrankaBarranka

20.5k13 gold badges65 silver badges83 bronze badges

Today we are with our another error solving article, & here we are going to show you & solve your VBA Runtime Error 91 Windows PC code problem from your Windows PC permanently. So, for that, all you have to do is just read and check out this below post once entirely fast so that you can surely grab some neat, natural solutions and the methods for getting rid out of this type of Error 91 Excel VBA problem.

This shows an error code message like,

Runtime Error 91

Object variable or With the block variable not set

This Error 91 object variable or with block variable set suddenly occurs when you are starting any program. This error is a significant error code problem on many of the users PC. This error is a common error problem on the Windows-based systems that usually appear randomly. This Error Code 91 may encounter with the Microsoft products. Old or corrupted registry keys may also cause this error. This error problem includes PC freezes, crashes & the possible virus infection. This issue even the result of coding errors in the app. This VBA Runtime Error 91 Windows problem appears to be due to the insufficient access rights on the PC.

Causes of VBA Runtime Error 91 Windows Code Issue:

  • When opening Excel
  • Runtime error

So, here are some quick tips and tricks for efficiently fixing and resolve this type of Error 91 Windows PC Code problem from you permanently.

How to Fix & Solve VBA Runtime Error 91 Windows Code Problem

1. Change DCOMCnfg.exe Settings –

Ensure that DCOMCnfg.exe file is set to allow “Everyone” to use it so that you can quickly fix and solve this VBA Runtime Error 91 Windows code problem from your PC.

2. By using this below Command on the RUN –

By using this below Command in the RUN

  • Go to the start menu
  • Search for RUN & open it
  • Type this below the following command in the Run window
    Regsvr32 c:windowssystem32scrrun.dll
  • Now, then click OK there
  • After completing, just close the tab
  • That’s it, done

By using this above command in the RUN can get back you from this VBA Runtime Error 91 Windows code problem.

3. Perform a full Windows PC Scan for Viruses or Malware –

Perform a full PC scan for viruses

  • Go to the Start Menu
  • Search for ‘Microsoft Security Essentials‘ & open it
  • Click on the “Scan Now” option
  • Before clicking on the ‘Scan Now‘ button,
  • Check that ‘Full‘ Scan option is selected already while scanning
  • That’s it, Done

It will perform a full PC scan for the viruses on your computer to fix this Runtime Error 91 excel vba problems.

4. Use a Registry Cleaner to Clean all the Registry of your Windows PC –

Clean or Restore the Registry

Clean your registry by any registry cleaner software so that it can fix and solve this VBA excel Runtime Error 91 Windows problem from your PC completely.

5. Disable the Script Debugging on the Internet Explorer –

Disable the Script Debugging on the Internet Explorer

  • Go to your Internet Explorer
  • Now, go to the Tools option there
  • Click on ‘Internet Options’ there
  • Now, click on the Advanced tab there
  • Now, scroll down to the Browsing
  • &, click on Disable Script Debugging to disable it
  • After completing, close the tab
  • That’s it, done

By disabling the script debugging on the Internet Explorer browser can fix and solve this Error 91 Excel VBA code problem from your PC.

These are the quick and the best way methods to get quickly rid out of this VBA Runtime Error 91 Windows PC Code problem from you entirely. Hope these solutions will surely help you to get back from this Error 91 object variable not set issue.

If you are facing or falling in this VBA Runtime Error 91 Windows PC Code problem or any error problem, then comment down the error problem below so that we can fix and solve it too by our top best quick methods guides.

Getting run time error 91 when opening Excel? or showing dcomcnfg.exe runtime error 91 while executing an application or open file explorer on Windows 10? This error usually occurs when a program attempts to access an object variable that hasn’t been initialized or set to a valid value. Here in this post, we discuss What is Run time error? Why getting dcomcnfg.exe runtime error 91, Explore possible solutions to fix this Error on Windows 10. 

Contents

  • 1 What is Run time Error?
  • 2 Why Getting Runtime Error?
  • 3 Fix Runtime Error 91 on Windows 10
    • 3.1 Disable Script Debugging
    • 3.2 Change DCOMCnfg.exe Settings
    • 3.3 Run the Program as an Administrator
    • 3.4 Reinstall the Problematic Program
    • 3.5 Update Windows and Installed Programs
    • 3.6 Clean Out Viruses
    • 3.7 Clean The Registry
    • 3.8 Ensure Object Libraries are Referenced
    • 3.9 Perform a System File Check

What is Run time Error?

A runtime error is a common error on Windows-based systems, caused by the programs which try and use the DCOMCnfg.exe file on your system. DCOMCnfg.exe is the most important program that is used to control various file permission on your system. Also, this helps to load up various programs on your computer. If this DCOMCnfg.exe get corrupted windows will display error message Runtime Error 91 frequently.

The error message will be like

Run time Error ’91’ :

Object variable or with block variable not set.

This error can occur in various programming languages such as Visual Basic for Applications (VBA) in Microsoft Office applications (e.g., Excel, Word, Access), Visual Basic (VB), and other languages that use object-oriented programming concepts.

Why Getting Runtime Error?

Normally this Runtime error 91 occurs when the DCOMCnfg.exe file gets damaged, corrupted or unable to be processed as reliably as possible.

Missing DLL, Invalid or incorrect object references, Missing object library references, Corrupted or outdated software, Compatibility issues or Malware or virus infections are common reasons cause Runtime error 91 on Windows 10.

You may find software updates that solve your runtime error as well as additional updates that you were otherwise unaware of. By keeping your computer updated with the latest software and hardware patches, you can solve current problems as well as prevent future ones.

The first thing to do is report the issue to the developer who may not be aware of it.

Next, you can turn off script debugging so that you don’t have to see this message every time the software encounters it. After all, the message is for the developer, not the end user.

Disable Script Debugging

Script debugging is made possible by a service called Machine Debug Manager. The easiest way to control it is through Internet Explorer.

  • Type Internet Options on Start menu search and click the first option.
  • Here on internet options move to Advanced Tab.
  • Now scroll down to Browsing and checkmark on Disable Script Debugging (Internet Explorer) and Disable Script Debugging (Other).
  • Runtime error 91 falls into the broad category of program errors that require updates from the developer.

disable script debugging on internet options

Change DCOMCnfg.exe Settings

The main cause of this error is thanks to the way that “DCOMCnfg.exe” blocks permissions on certain files and programs. DCOMCnfg.exe is a program used to help your computer control various aspects of the system. From making it load its programs to helping you control file permissions. It’s often the case that DCOMCnfg.exe will block public access to certain files And That creates the Runtime 91 error as a result.

You should load up DCOMCnfg.exe on your PC and change the permissions so that it grants access to “Everyone”.

Run the Program as an Administrator

Certain programs require administrative privileges to function correctly. If Runtime Error 91 persists, try running the program as an administrator.

  • Right-click on the program’s executable file or shortcut icon.
  • Select “Run as administrator” from the context menu.
  • Check if the error still occurs.

Reinstall the Problematic Program

If the Runtime Error 91 occurs consistently when running a particular program, it is possible that the installation files have become corrupt.

First, uninstall the program from your system.

  • Press the Windows key + X on your keyboard and select “Apps and Features” from the menu.
  • Locate the problematic program in the list, click on it, and then select “Uninstall.”
  • Once uninstalled, visit the official website of the program and download the latest version.
  • Install the program again following the provided instructions.

Update Windows and Installed Programs

Outdated operating systems and software can often lead to compatibility issues and runtime errors. You must check and install latest Windows updates As these updates are created specifically to fix issues like this. Check for updates of Windows OS and its Installed application software. Updating can work greatly, It fixes many bugs. So, You will have a good chance to get rid of Runtime Error 91.

  • Go to “Settings” by clicking on the Start button and then the gear icon.
  • In the Settings window, select “Update & Security.”
  • Click on “Check for updates” to search for and install any available updates.

Download Windows 10 update

Additionally, update any programs that you suspect may be causing the error by visiting their official websites and downloading the latest versions.

Clean Out Viruses

Viruses and malware infections are another big cause of the Runtime 91 error. And in order to prevent them from being such a big issue for your system We recommend performing a full system scan. Ensure that your antivirus software is up to date with the latest virus definitions.

Antivirus scan

Clean The Registry

The ‘registry’ is a central database for Windows which stores all the settings and options that your computer requires to run. As you use all the software on your PC, the registry is being read 100’s of times to help it recall various settings and information that your computer needs to run, and this can cause a big problem.

The issue is that since the registry contains so many files and settings that Windows requires running Most of the time, this database is continually becoming damaged and corrupted. This is a big problem because if it cannot read the settings it needs, it can cause the Runtime 91 error.

To fix this problem, it’s highly recommended you use a registry cleaner, like Ccleaner.

Ensure Object Libraries are Referenced

Sometimes, missing or incorrect object library references can trigger Runtime Error 91.

  • Open the Visual Basic Editor by pressing “Alt+F11” in the program where the error occurs.
  • Click on “Tools” and select “References” from the dropdown menu.
  • In the References dialog box, check if any references are marked as “Missing.” If so, uncheck them and search for the correct reference.
  • Locate the correct reference in the list and check the corresponding box. Click “OK” to save the changes.

Perform a System File Check

Corrupted system files can cause various errors, including Runtime Error 91. Windows 10 includes a built-in tool called System File Checker (SFC) that scans and repairs system files.

To run SFC, follow these steps:

  • Press Windows key + S, type cmd and select run as administrator
  • In the command prompt window type “sfc /scannow” without quotes and press Enter.
  • Wait for the scan to complete and follow any on-screen instructions if prompted.

Also Read

  • Fix Runtime Broker High CPU Usage in Windows 10
  • Disable Windows 10 startup programs To fix slow startup and boot faster
  • Troubleshoot blue screen errors on Windows 10 (Updated)
  • Perform a Clean Boot to diagnose issues on Windows 10
  • This page has been blocked by the Chrome extension “err_blocked_by_client”
  • 7 Ways to Fix Google Chrome Not Installing on windows 11

Question

Issue: How to fix Runtime Error 91 on Windows?

I would like to get some help with an error message: ”Runtime Error 91: Object variable or with block variable not set”. I see this message every time I am opening Word. It is newly installed on my computer, but everything went fine during the installation and I cannot understand why it is showing the error. Could you help to find the reason and fix this error, please?

Solved Answer

“Runtime Error 91: Object variable or with block variable not set” is a runtime error that can occur on all versions of Windows-based operating systems. It is a relatively common error, and the main culprit is usually the DCOMCnfg.exe file, which is often used to configure permissions and set system-wide security settings.

When this file is corrupted, or some other issues arise, the program cannot work properly, and Runtime Error 91 pops up on the screen. However, there might be other reasons for the issue to arise, and we will explore all the methods that could help you fix Runtime Error 91.

There are several different scenarios when the Runtime Error 91 can show up, such as during program installation, startup operation, or a shutdown, although some users may also see the error when they upgrade their Windows to a newer version. The time when the issue is first spotted also determines the measures that need to be taken to fix Error 91 on the machine.

Runtime Error 91 on WindowsFix Runtime Error 91 on Windows

When the Runtime Error 91 occurs after the installation of the program, the reason why it happens is related to the problems with a link to the downloaded software. Often Runtime Error 91 appears when this link is missing or interrupted. What is more, this error is often followed by the “Error 59999 – Application-defined or object-defined error.”

The latter error might occur when generating a report to XML/Enhanced XML and is is caused by insufficient permissions on the FRxXMLTag.XML file in the FRx directory. Thus, in order to get rid of this problem, you need to fix this file.

Note: if you want to repair various Windows errors and BSODs[1] automatically, do not hesitate to use FortectMac Washing Machine X9.

Method 1. Reinstall the problematic application



Fix it now!




Fix it now!

To repair damaged system, you have to purchase the licensed version of Fortect Mac Washing Machine X9.

Issues with variables might be caused by file corruption. In order to fix that corrupted data within the system files, users could run a built-in SFC scan. However, this method will not work if the corrupted files are not those of Windows but the external application, even if it is one of the core programs that run on the PC. Thus, you should try to reinstall the problematic app that causes the Runtime Error 91.

  • Type in Control Panel into Windows search and hit Enter
  • Go to Programs > Uninstall a program
  • From the list, select the app, right-click and pick Uninstall

    Reinstall the problematic appReinstall the problematic app

  • Once done, re-install the app and see if that helps to fix Runtime Error 91

Method 2. Update Windows



Fix it now!




Fix it now!

To repair damaged system, you have to purchase the licensed version of Fortect Mac Washing Machine X9.

The Runtime Error 91 might be related to .NET Framework[2] and Visual Basic, updates for which are applied via Windows updates. Therefore, make sure you Windows is up to date:

  • Right-click on Start button and pick Settings
  • Select Update & Security
  • Lick Check for updates

    Update WindowsUpdate Windows via Settings

  • Wait till Windows downloads and installs all the required updates
  • Reboot your PC

Method 3. Scan your machine for malware



Fix it now!




Fix it now!

To repair damaged system, you have to purchase the licensed version of Fortect Mac Washing Machine X9.

Malware[3] can cause all sorts of problems on your computer, and also corrupt multiple files that are related to either system or program files. Therefore, malware can be one of the factors why you are facing Runtime Error 91. To make sure that this is not the case, you should scan you computer with reputable anti-malware software.

There are plenty of paid and free third-party anti-malware solutions available online, so you can choose based on your needs. However, you can also use Windows Defender (now known as Microsoft Defender) to perform a full system scan in order to make sure no malicious files are present.

  • Click on system tray arrow and double-click the Windows Security icon
  • Select Virus and threat protection
  • Pick Scan options below Quick Scan button
  • Select Full scan option and click Scan now

    Scan the PC for malwareYou can use Windows Defender to perform a full system scan

Method 4. Set DCOMCnfg.exe to be allowed to run by “Everyone”



Fix it now!




Fix it now!

To repair damaged system, you have to purchase the licensed version of Fortect Mac Washing Machine X9.

  • Type in DCOMCnfg.exe into Windows search box and hit Enter
  • In the Component Services window, expand the following: Component Services > Computers > My Computer
  • Right-click on My Computer and select Properties
  • Select COM Security tab and under Access Permissions pick Edit Limits
  • Pick Everyone from the groups and make sure that Local and Remote Access are set to Allow

    Configure DCOMCnfg.exe fileConfigure DCOMCnfg.exe file

Method 5. Give full control to FRxXMLTag.XML file



Fix it now!




Fix it now!

To repair damaged system, you have to purchase the licensed version of Fortect Mac Washing Machine X9.

In case the Runtime Error 91 is followed by the Error 5999, you should perform the following steps:

  • Run Windows as administrator
  • In Windows Explorer browse to FRx directory.
  • Right-click on the FRxXMLTag.XML file and select Properties.
  • When in Properties, click the Security Tab.
  • In Security Tab, add the group Everyone and select Full Control.
  • Click OK.

Repair your Errors automatically

ugetfix.com team is trying to do its best to help users find the best solutions for eliminating their errors. If you don’t want to struggle with manual repair techniques, please use the automatic software. All recommended products have been tested and approved by our professionals. Tools that you can use to fix your error are listed bellow:

do it now!

Download Fix
 

Happiness
Guarantee

do it now!

Download Fix
 

Happiness
Guarantee

Compatible with Microsoft Windows
Compatible with OS X

Still having problems?
If you failed to fix your error using FortectMac Washing Machine X9, reach our support team for help. Please, let us know all details that you think we should know about your problem.

Fortect — a patented specialized Windows repair program. It will diagnose your damaged PC. It will scan all System Files, DLLs and Registry Keys that have been damaged by security threats.Mac Washing Machine X9 — a patented specialized Mac OS X repair program. It will diagnose your damaged computer. It will scan all System Files and Registry Keys that have been damaged by security threats.
This patented repair process uses a database of 25 million components that can replace any damaged or missing file on user’s computer.
To repair damaged system, you have to purchase the licensed version of Fortect malware removal tool.To repair damaged system, you have to purchase the licensed version of Mac Washing Machine X9 malware removal tool.

A VPN is crucial when it comes to user privacy. Online trackers such as cookies can not only be used by social media platforms and other websites but also your Internet Service Provider and the government. Even if you apply the most secure settings via your web browser, you can still be tracked via apps that are connected to the internet. Besides, privacy-focused browsers like Tor is are not an optimal choice due to diminished connection speeds. The best solution for your ultimate privacy is Private Internet Access – be anonymous and secure online.

Data recovery software is one of the options that could help you recover your files. Once you delete a file, it does not vanish into thin air – it remains on your system as long as no new data is written on top of it. Data Recovery Pro is recovery software that searchers for working copies of deleted files within your hard drive. By using the tool, you can prevent loss of valuable documents, school work, personal pictures, and other crucial files.

  • Ошибка runtime error 424 object required
  • Ошибка runtime error 339 mscomctl ocx как исправить
  • Ошибка runtime error 3001
  • Ошибка runtime error 217 at 004bb10d autodata как исправить
  • Ошибка runtime error 203