Fix Error Code 2147467259

Learn to fix the run time error code 2147467259 by reading this tutorial. This error is most commonly associated with Microsoft Access and to an extent Microsoft Excel.

When does the run time error -2147467259 occur?

When you open Microsoft Access and a form through Automation and set focus to the form’s custom menu bar, you receive the following Microsoft Visual Basic error message:

Run-time error ‘-2147467259 (80004005)‘:
Method ‘SetFocus’ of object ‘CommandBarPopup’ failed
What causes this error?
SetFocus fails because the control (in this case the menu bar) is not visible in the user interface at the time that the Automation code is executing.
If this is the error code that you receive then you can use the following guide to resolve the error code -2147467259, however, if you have a different string of numbers to the end of the code then you can skip ahead to the Excel fix.

Fix Runtime error ‘-2147467259 (80004005)’ – Microsoft Access

The following steps are to be performed by professionals who are able to code and work with coding terms accordingly. (Skip ahead if you’re not tech savvy)

Method 1: Trap for the Error

Enter a function similar to the following:

Function AutomationTest()
   On Error GoTo AutomationErr

   <Automation code goes here>

AutomationExit:
   Exit Function

AutomationErr:
   If Err.Number = -2147467259 Then
      Resume    'until control is visible.
   Else
      <handle any other errors>
   End If
End Function

If you need further help then try using method 2 on the next page!

Method 2: Insert a Time Delay

Set focus by using code behind the form instead of the Automation code. For example, set the form's TimerInterval to 1000 (the value assigned may vary), and then add the following code to the form:
Private Sub Form_Timer()
   Me.TimerInterval = 0
   Application.CommandBars.ActiveMenuBar.Controls(1).SetFocus
End Sub

The run-time error that is mentioned in the “Symptoms” section occurs only when you use Automation. The occurrence varies based on whether or not Access is idle after the form opens, but before the Automation code attempts to set focus to a control. Variations in CPU speeds, program timing, and operating systems may cause this behavior to occur on some computers, but not others. Let's see how to resolve it on the next page.

Try this if you're not good at coding

If you’re not tech savvy then you can try a simple and straightforward method to resolve the issue.

1) Uninstall MS Access and Visual Basic
2) Reinstall both of MS Access and Visual Basic

Sometimes this can help resolve the issue and saves you the time of having to go through all the coding. That is the work around for the error code if it appears in Microsoft Access, now, let’s talk about the error code with regard to Microsoft Excel.

Micorsoft Excel Runtime Error

If you encounter the error while using Microsoft Excel then consider the following:

  • You have a macro that sets a property of a chart in Microsoft Excel. For example, the macro sets the MaximumScale,MinimumScale, Title, Axis, or Legend property of a chart.
  • You protect the worksheet. When you do this, you click to select the Edit objects check box in the Protect Sheet dialog box.
  • You run the macro.

In any of the above scenarios you will most likely encounter an error message that looks something like:

Error message 1

Run-time error ‘-2147467259 (80004005)':Method ‘MaximumScale’ of object ‘Axis’ failed
or

Error message 2

Run-time error ‘-2147467259 (80004005)':Automation errorUnspecified error

This happens because the Excel object model for the chart is disabled on a protected worksheet and luckily there is an easy and simple work around to the issue. In order to work around this problem, unprotect the worksheet to enable the macro to run. You can manually unprotect the worksheet or you can do so by using the Unprotect method in the macro. Thanks for reading:  How to Fix Error Code  2147467259  Source 1 Source 2

Add Comment