I have weird bug - then I open VBA Editor I can edit and create macros for sheets just fine, but then I try to edit macros for Workbook (create on_open event) I can't access ThisWorkbook tab in VBA Editor. Then I click it - nothing happens. What causing this problem? If I create new Excel workbook I can access this part with no problem (but that is not an option, since it would be to much work to move everything to new workbook).
EDIT: I turned off SOLVER add-in and the problem is gone. But I am still baffled why it was happening and how to avoid this problem in the future, since I sometimes need SOLVER add-in enabled.
EDIT 2: After writing desired routines for on_open and before_close events I restarted my Workbook to test it out. Events did not activated and I am locked from Workbook tab in VBA Editor again. Strangely everything worked fine then I tested it on older Excel version (MS Office 2013, version I am working with - MS Office 2016 version 1912 ) in other PC.
Related
Suddenly I have a weird problem with my Excel app.
I've looked the internet and in this site, found similar problem but it seems their problem is because of some codes. While mine, there is no code at all.
At first, after I close my xlsm work file (which has some modules with the code), then I open the VBA editor, sometimes it gives me message box "Out of Memory", sometimes it gives me "catastrophic failure" message box, sometimes there is no message box, but one thing for sure, in the VBA editor it still show the workbook which I've just close.
Strange thing, if I open the Excel app first (which gives me a blank worksehet by default), then I double click my xlsm working file, then close it, then open the VBA editor, there never any message box and in the VBA editor also there is no workbook which I've just close.
So it happen only if I directly open my xlsm working file... or any other xlsm file which has a module, even a blank module.
It doesn't happen if I directly open (by double clicking) an xlsx file.
Curious, I open the Excel app (it gives me a blank worksheet by default), Insert a blank module in VBA editor then save the workbook as Book1.xlsm.
.
.
.
Then I close the workbook.... and I see that in the VBA editor it still has the Book1.xlsm there.
.
.
.
Then I just close the Excel app, and open it again. Then I double click the Book1.xlsm.
Close the Book1.xlsm, there is no Book1.xlsm left in the VBA editor.
.
.
.
Then I close the Exel app. I directly double click the Book1.xlsm
Close the Book1.xlsm. Again, there is still Book1.xlsm in the VBA editor.
I've tried to repair the Microsoft Office 2010 via Control Panel ---> Programs.
After it's done, MS Office ask to reboot. So I reboot. Directly double click the Book1.xlsm, close the Book1.xlsm. No joy. VBA editor still show Book1.xlsm left there.
Although I realize that maybe the last resort I need to do is to uninstall MS Office and then reinstall it back, but still I wonder, if anyone here know what cause this kind of problem ? What cause a blank xlsm workbook with a blank module - after it close, the VBA editor still show it ?
Why if I open the Excel app first, then open the xlsm file, the problem does not exist ?
FYI, all the subs in my working xlsm file can still run without problem.
Any kind of explanation would be greatly appreciated.
Thank you in advanced.
I have searched on the internet to see if I can find any references to these problems without success.
Occasionally, in Excel 2016 or Excel 2019 I open a macro-enabled workbook and discover all macros within the file have disappeared. This is despite enabling the macros when the workbook is opened. I determine there are no macros available by selecting Macros on the Developer Tab. No macros will appear in the macro dialog box. In addition, although a number of macros are linked to buttons within the file, I will try to use these and none will work.
If I save, close and re-open the workbook in either of these versions of Excel the macros still do not reappear. However, if I re-open the file in Excel 2010 the macros are available with all working as intended. If I save the file in Excel 2010, close it and then reopen it in Excel 2016 or Excel 2019 the macros will have reappeared.
Occasionally, and again in Excel 2016 or Excel 2019, when I open one of my more complex, macro-enabled files it will not open correctly and instead Excel indicates it is corrupted and requires repairs. I do not allow Excel to make the repairs and instead close the file, reboot Excel and try reopening the file. Again, Excel will indicate the file is corrupted and attempt repairs which are not accepted. However, if I switch to Excel 2010 and open the same file no problems are encountered with the file opening normally. Once it has opened, if I then save the file in Excel 2010 and close it, the file will then open normally in Excel 2016 or Excel 2019.
Might you have an answer to why this is happening?
I have a workbook in which I consolidate data from various CSV files. There are a number of macros in this file including ones to add new sheets to the file, which is on a shortcut key Ctrl+Shift+N. This has been working perfectly for many years. This morning the shortcut key does absolutely nothing. If I go to the Excel developer tab and click on the Macros button, the list of macros is empty. However, if I open VBA I can run the macro from there and it still works perfectly.
I run Office Professional Plus 2019 and it ran an update yesterday. Does anyone know of a new setting introduced that may hide the macros in Excel itself. Note that macros are enabled on this workbook.
Just for closure should someone else stumble across this. The problem was related to the specific file. It somehow got "partially" corrupted. Still worked and could fire macros from VBA IDE as well as linked buttons, just not with shortcut keys as macros not "visible" in Excel view. File degraded further to a point where it could no longer save.
Recently I've stumbled upon a strange behaviour of VBA. In my Microsoft Excel Macro-Enabled Worksheet I have several sheets, with one named "Log". While I was debugging a code, I added a new watch with an expression Worksheets("Log"). When I click on the + box in front of it to expand the expression, Welcome to Outlook 2016 wizard pops up?!
On each subsequent click on the expression, New Profile window pops up.
Funny thing is, I don't even use Outlook and it alone cannot be uninstalled from the system and rest of the Office package. So, what is happening here and how can I prevent this strange behaviour?
I have it too, also when I have the watch set to a page of the worksheet.
It seems to happen when I forget to activate the sheet before I access it. After doing that the Macro and watch behave as expected.
I have a user who just got a new computer (Windows 10 Pro running Office 2013) and he can no longer open a macro enabled workbook.
I finally identified that the Userforms are causing the issue when I created a new workbook and added some VBA to it. Everything worked fine until I went to insert a Userform, that's when it crashed. I did some additional testing and found he can open .xlsm files except when a userform is in the VBA.
I looked into the References in the VBA window and checked the libraries, he seemed to have what he needed and I added anything I thought was missing but nothing helped.
Visual Basic for Applications
Microsoft Excel 15.0 Object Library
OLE Automation
Microsoft Office 15.0 Object Library
Microsoft Forms 2.0 Object Library (keeps unchecking itself but even when checked doesn't help)
Ref Edit Control
What references could I be overlooking here?
The VBA code is not affecting it, I ran the opening code without any forms and it opened and enabled macros just fine.
What is preventing Excel from running a macro enabled workbook with userforms or adding a userform?