Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rubberduck VBA: What can cause a Resolver Error?

Tags:

vba

rubberduck

Thank to this question : Rubberduck UI submenus are disabled, I know that I may have to hit the "Refresh button" to use RubberduckVBA.

One of the error that can follow is apparently the "Resolver Error".

enter image description here

What are the different cases in which such a Resolver Error may occur?

like image 891
Akita Avatar asked Mar 05 '23 13:03

Akita


2 Answers

TL;DR: Rubberduck is past due for a new "official" release!

Disclaimer: I manage & contribute to the Rubberduck OSS project.

An exception was thrown while traversing the parse trees. It's hard to tell exactly what happened, because parsing+resolving VBA code is a very complex, multiple-steps process.

To find out specifically what went wrong, you need to look at the logs - logging being disabled by default (it's rather verbose), you need to enable it through the settings dialog:

Rubberduck settings dialog

Set the minimum log level to Trace for the full gory details of everything the parser/resolver is doing, or Error for a less verbose log that only includes the exception information; you can then post this log (or parts of it) into a new issue, and the project devs will promptly tag/label it accordingly, inspect the log/exception details, and determine whether the problem was fixed in a later pre-release build, or if it's a new bug that needs to be fixed.

Since pretty much every single feature needs an accurate understanding of the code in the VBE, Rubberduck devs take parser/resolver issues extremely seriously.

If you're using the latest "green" release (v2.2.0), I'm pretty sure the problem was fixed since then. Latest "pre-release" build has annoying problems with the autocompletion feature (will definitely be fixed by v2.3.0), but the resolver works very well now :)

like image 121
Mathieu Guindon Avatar answered May 25 '23 14:05

Mathieu Guindon


At least one of the case is the following:

A Function or Sub doesn't compile and the developer is not aware of that when running the VBA project because the Sub is never called.

Solution:

This "junk" code can be spotted in Trace-level logs of Rubberduck.

For exemple in my case:

Sub CleanSheetOut()
Worksheets(sheetOut).Range("A1:XFD10485576").Clear
Worksheets(sheetOut).Range("A1:XFD10485576").Interior
        .Pattern = xlNone
       .TintAndShade = 0
     .PatternTintAndShade = 0
End Sub

...was incorrect (didn't compile) but was never called, so the project was running fine but Rubberduck couldn't resolve.

The correct code :

Sub CleanSheetOut()
   Worksheets(sheetOut).Range("A1:XFD10485576").Clear
   With Worksheets(sheetOut).Range("A1:XFD10485576").Interior
      .Pattern = xlNone
      .TintAndShade = 0
      .PatternTintAndShade = 0
   End With
End Sub

...compiles and lets Rubberduck parse and resolve normally.

The logs: enter image description here ... showed the faulty Sub and in which module I could find it.

Insight from the Rubberduck development team:

Whether the VBE compiles on the fly depends on the compile settings in the bottom right of the Editor tab of the Tools->Options menu.

We actually try to compile the project and warn the user that the project does not compile. However, the forementioned VBE settings can interfere with that. Moreover, compilation before refresh might be deactivated in Rubberduck's own settings.

See this Github thread for more details.

like image 34
Akita Avatar answered May 25 '23 16:05

Akita