Skip to content

Mocking doesn't work with objects other than Excel.Application #6246

Open
@dan-ignat

Description

Rubberduck version information

Rubberduck version [2.5.92.6353]
Operating System: [Microsoft Windows NT 10.0.19045.0, x64]
Host Product: [Microsoft Office x64]
Host Version: [16.0.18324.20194]
Host Executable: [EXCEL.EXE]

Description
I was able to successfully use the mocking example of Excel.Application described in the Quick Start here:
https://github.com/rubberduck-vba/Rubberduck/wiki/VBA-Moq-Mocking-Framework#quick-start

But as soon as I tried mocking a different Excel object, like Excel.Range, Excel.Font, Excel.Interior, I got the following error when executing e.g. Mocks.Mock("Excel.Range"):

Run-time error '-2146233086 (80131502)':

The supplied Excel.Range was not found. The class may not be registered or could not be located with the available metadata. Parameter name: ProgId

Same error for Excel.Font and Excel.Interior.

Can any Excel objects other than Excel.Application be currently mocked?

To Reproduce
Steps to reproduce the behavior:

  1. Just try a simple:
    Dim Mock As Rubberduck.ComMock: Set Mock = Mocks.Mock("Excel.Range")
  2. See error

Expected behavior
I'm expecting to be able to mock most Excel objects, not just Excel.Application.

Screenshots

Logfile

Additional context

Metadata

Assignees

No one assigned

    Labels

    feature-mocking-apifeature-unit-testingsupportWhether you're using Rubberduck or you've forked it and have questions, never hesitate to ask!

    Type

    Projects

    • Status

      No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions