Run-time error '-2032465766 (86db089a)' "Requested operation is presently disabled."

3.1k views Asked by At

This is weird. Why does Visio throw exception?

Scenario:

  1. Open new instance of Visio.
  2. Press CTRL+N for a blank new document.
  3. Goto VB editor.
  4. Open the default "ThisDocument" code file.
  5. Paste the following code.

    Sub test()
        Application.ActiveWindow.SelectAll
    End Sub
    
  6. Execute the subroutine "test".

You will observe this exception for code line "Application.ActiveWindow.SelectAll":

---------------------------
Microsoft Visual Basic for Applications
---------------------------
Run-time error '-2032465766 (86db089a)':



Requested operation is presently disabled.
---------------------------
OK   Help   
---------------------------

Does anyone know why?

3

There are 3 answers

1
Nikolay On BEST ANSWER

The error "Requested operation is presently disabled" means literally this - the requested operation is disabled (in menu) at the moment (because it makes no sense).

In your case, you can't do "Select all" because there is nothing to select (you have no shapes). So the command "select all" is disabled.

If you had some shapes on the drawing, this code would run just fine.

8
Andy G On

This procedure doesn't belong in the ThisDocument module, which is intended for Document events. Right-click ThisDocument in the Project Explorer on the left and choose Insert Module, cut and paste the code in here.

If you add one or more shapes to the document and click to select one of them before running your code then it works. This is because previously there was no ActiveWindow, which was the reason for the error. Selecting all shapes is disabled if there is no active window.

0
Nayan On

I am feeling that Visio throws exception by design, in case you try to run select operation via code when there is no object in document.

I hope this change in future versions.