rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 299 forks source link

Code Explorer Doesn't Update when Adding New Worksheet #4782

Open SmileyFtW opened 5 years ago

SmileyFtW commented 5 years ago

Version 2.4.0.4511 OS: Microsoft Windows NT 10.0.17134.0, x64 Host Product: Microsoft Office x86 Host Version: 16.0.11231.20130 Host Executable: EXCEL.EXE

Description I add a new worksheet to a workbook; no worksheet shows up in the Code Explorer even after Refresh. Closing and Reopening the workbook nor the entire Excel app isn't sufficient even though the CE window removes the project after it is closed, and adds it back when reopened.

I have renamed my Project from "VBAProject" to a meaningful name and put @Folder("Workbook.Worksheets") in each of the other worksheet code-behinds.

Only after I use the VBE Project Explorer window to add @Folder("Workbook.Worksheets") in the code-behind does the worksheet show up in CE.

To Reproduce Add a new worksheet using the "+" icon on the sheet tab selector bar in the Excel window, Double-click the new tab to rename the sheet Go into VBE, refresh Code Explorer and via the RD main drop down menu Refresh. The new worksheet isn't in the CE window anywhere.

Expected behavior Should see the new worksheet under the Project.

Screenshots N/A

Logfile Windows cannot find %APP_DATA%

bclothier commented 5 years ago

FYI - it should be %APPDATA%, not %APP_DATA%. (the template has been fixed, sorry for the inconvenience!)

comintern commented 5 years ago

I can't replicate this. Are you referring to the worksheet name not showing up in the Code Explorer, or the worksheet document class itself? Changing the name of the worksheet on the worksheet tab doesn't expose any events that are visible to Rubberduck - we only see changes to the code name. Even in that case, the name in parentheses after the code name should refresh on reparse.

Note that by default, any newly added modules (added via the RD menus) will get a folder name matching the project name. The exception would be modules added via the host (i.e. using the "+" icon to add a new sheet), but any module without a folder annotation are put in the default project name folder. So in a brand new workbook with no changes they should go into the VBProject folder.

If you're able to replicate this on your system, could you grab the log file before it's over-written and post it here? You can get to the folder from Rubberduck -> Settings -> General Settings -> Show Log Folder. Since you also say that it persisted when the workbook was reopened, it may also be helpful if you're able to get an otherwise empty workbook into this state and upload that.

SmileyFtW commented 5 years ago

I am referring to the worksheet document class not showing up. I am unaware of a way to add a worksheet to the workbook via RD, only via the Excel interface.

Since it didn’t show up in the RD CE I used the properties pane of the VBE to change the codename; RD CE didn’t pick it up at that time either after initiating a refresh.

The only time the worksheet appears to be picked up is when I add the ‘@Folder annotation.

Could it have anything to do with the fact that I have put an @Folder annotation in every module and so there is nothing in the VBAProject (default)? I also have renamed VBAProject to a meaningful name.

Attached is the log file I have. It looks to be an old one. When I go to the Settings it indicates that Minimum Log Level is set to No Logging. What should it be set to so it will capture what you need when I try to replicate what I have seen?

Thanks!

comintern commented 5 years ago

Thanks for following up - that gives me a couple more things to try in attempting to reproduce this.

That was indeed an old log - I've removed it because GitHub is being stupid and won't let me collapse it into a code block since it came from an email. Ideally, we like to see logs that are set to at least Debug. RD currently defaults to No Logging after the add-in has been successfully run at least once.

SmileyFtW commented 5 years ago

FYI - it should be %APPDATA%, not %APP_DATA%. (the template has been fixed, sorry for the inconvenience!)

Thanks! Don't know how that underscore snuck in!