Rubberduck: COM Collector failing to resolve VBA library, including project, module and member names

Created on 14 Jun 2018  ·  11Comments  ·  Source: rubberduck-vba/Rubberduck

Rubberduck thinks that internal function RGB is a variable...

EXAMPLE:
control.BackColor = RGB(255, 0, 0)

CODE INSPECTION TEXT:
Suggestion: Consider renaming variable 'RGB' - (workbook.xlsb - [L­^Pʺ£$'HòŏekËøù™s|÷Å) project.name, line 76

NOTE:
Maybe a separate issue, what is all the junk seen in that code inspection text?

bug resolver

All 11 comments

Seems we're not picking up RGB from whereever it originally comes from. Either something's fishy with the COM collector or we need to add another special declaration

Been having COM collector issues too lately, but not in dev, only in release builds. This looks like it. Do you have any log entries about failing to load type libraries?

The junk text seems to be a failure to get the document module's display name correctly - assuming the worksheet isn't actually named "L�­^Pʺ�£�$�'�HòÅ��ekËøù™s|÷Å��"

Regarding the strange text, is the module name rather long. That would trip up the logic for getting the module name from the window caption because of an obscure bug in the caption property in the VBE API. (I always thought we only used that to qualify calls via Application.Run, which we do not do anymore.)

The module name is 11 characters long. That doesn't seem excessive to me.

@A9G-Data-Droid hmm, there goes the only known explanation for such junk content...

Should I open a different issue for that?

Yeah, we need to repro & fix that.

When testing all of the members of VBA.Information, all of the functions are recognized as variables. Worse still, qualifying the member with the library name or module name, results in the library and module being recognized as variables, and then the functions aren't recognized at all (they're treated as if they're late-bound members of an unknown type?)

Note that the call to stdole.LoadPicture is recognized correctly, which suggests that there's a problem reading/resolving the VBA library in particular.

Given this code:

Sub foo()

    Dim x As Variant

    Set x = VBA.Err()
    Set x = Information.Err()
    x = IMEStatus()
    x = IsArray(x)
    x = IsDate(x)
    x = IsEmpty(x)
    x = IsError(x)
    x = IsMissing(x)
    x = IsNull(x)
    x = IsNumeric(x)
    x = IsObject(x)
    x = QBColor(1)
    x = RGB(1, 2, 3)
    x = TypeName(x)
    x = VarType(x)

    'Non-VBA library functions
    Set x = LoadPicture()
    Set x = stdole.LoadPicture()

End Sub

These inspections result:

Error: Local variable 'VBA' is not declared - (Book1) VBAProject.Module1, line 8
Error: Local variable 'Information' is not declared - (Book1) VBAProject.Module1, line 9
Error: Local variable 'IMEStatus' is not declared - (Book1) VBAProject.Module1, line 10
Error: Local variable 'IsArray' is not declared - (Book1) VBAProject.Module1, line 11
Error: Local variable 'IsDate' is not declared - (Book1) VBAProject.Module1, line 12
Error: Local variable 'IsEmpty' is not declared - (Book1) VBAProject.Module1, line 13
Error: Local variable 'IsError' is not declared - (Book1) VBAProject.Module1, line 14
Error: Local variable 'IsMissing' is not declared - (Book1) VBAProject.Module1, line 15
Error: Local variable 'IsNull' is not declared - (Book1) VBAProject.Module1, line 16
Error: Local variable 'IsNumeric' is not declared - (Book1) VBAProject.Module1, line 17
Error: Local variable 'IsObject' is not declared - (Book1) VBAProject.Module1, line 18
Error: Local variable 'QBColor' is not declared - (Book1) VBAProject.Module1, line 19
Error: Local variable 'RGB' is not declared - (Book1) VBAProject.Module1, line 20
Error: Local variable 'TypeName' is not declared - (Book1) VBAProject.Module1, line 21
Error: Local variable 'VarType' is not declared - (Book1) VBAProject.Module1, line 22

Possibly related: #4045

Closing against #4181.

Was this page helpful?
0 / 5 - 0 ratings