Excel not responding when I try to open VBE - vba

I need help, Excel is not responding. I have written a lot of code in VBA and right now I can't even open VBE. I can open the workbook okay, but every time I make any change to one of the cells (I have a lot of code that is triggered by the worksheet_change event based on the cell that was changed) it will not respond. I'm 80% sure it is something wrong with my code, but I can't open the VBE to diagnose because that will also cause Excel to not respond, forcing me to close the application.
I have tried opening Excel in user-initiated safe mode, but this doesn't fix anything.
Any ideas??

Change your Security Settings to prevent macro execution. You can then open file and examine the macros without fear they will execute.
EDIT#1:

Close all files and programs. Then, restore your computer to an earlier time period. You can find out how to do this in 'Control Panel'. This will fix it.

Related

Disable Macros from Safe Mode

I wrote a macro that now is causing issues with MS Word. I can only open the document in safe mode and cannot figure out how to delete the macro from safe mode. I don't have access to any of the features in safe mode and the macro isn't even showing up. I tried changing the Trust Center settings but none of those options make a difference. Unfortunately I was very dumb and made it a macro on all documents so I can't open any documents without going into safe mode. help!
To be more specific, I believe the code that broke my MS Word was a OnError GoTo ErrorHandler where I tell it to skip to the next if there is an error. I am working on converting equations to a professional format and some of them don't have the right syntax for the conversion so for now I wanted it to ignore those equations and convert the next equation. That is the only change I have made recently that could be the problem.
An additional edit: the macro is coded to run on open. It was running fine before I added the ErrorHandler. I'm sure this is also a huge part of the problem, but a simple solution may not be the right fix since it automatically runs when I open the document. I can't access anything in safe mode.
If you are talking about the "Normal" document in the project explorer, resetting it is easy.
Simply navigate to %AppData%\Microsoft\Templates and either delete or rename the Normal.docm file. Once you reopen Word it will regenerate a brand new file automatically - one that contains no code.
You created an AutoOpen macro which only fires when a document is opened. Presumably this macro is stored in your Normal template.
When you first start Word the macro should not run as you are not opening a document. If Word doesn’t automatically create a new blank document you can safely do so. You will then be able to access and edit the macro you created.

Pause VBA Macro to allow manual input of data

I have an Excel workbook macro that opens another workbook and starts copying data into it and formatting it. At one point in the process, I want the macro to pause and let the user manually enter data into the target workbook and then resume processing.
MsgBox, Application.Wait(), and Sleep are all application modal and will not let the user update anything in the other workbook while they are executing.
I found this while searching for a solution. It gets me halfway there in that I can manipulate the other sheet but only with my mouse. No keyboard presses get sent to the workbook.
Any ideas on getting all the way there?
I was thinking that I could just have two macros. The user would run one, then perform his manual tasks, then run the other. This appears to work but I would have to convert everything to globals so hopefully, someone has a better idea.
Thanks!
Depending on the macro being run to copy and paste, is the main concern with user intervention during execution of the macro getting the active cell/sheet (if being used) back to being active after the user manipulates something.
I'd recommend storing the active cell/sheet address in a variable prior to the Application.Wait() and then setting the active cell to that stored value on resume.
Without a posting of what your macro is doing though, it is hard to know if this suggestion helps your current situation.

Excel VBA macro runs from the VBA editor but not from the Macro window

I have a macro written in excel that has now stopped being able to run from the Macro window in the main excel window. It runs fine when I start it from the editor itself and I have another macro in the same file that also runs fine, and displays properly in the macro window. Please see picture.
If anyone has any idea why this is happing I'd be grateful, its a pain to run at the minute...
Running excel 2013 if that matters.
Thanks!
EDIT
Both subs are stored in the same file, the one highlighted in the picture above
Edit 2
The issue has weirdly resolved itself now, I did absolutely nothing and it fixed itself. would still like to know the cause
One is in a module and the other is in "ThisWorkbook".
You need to reference it from ThisWorkbook.
Problem has magically resolved itself without me doing anything, very weird. If anyone has an idea I'd still be interested to know why this happened

Lock or Freeze VBA Code to Prevent Editing

Is there any way I can lock or freeze the VBE editor to prevent others from accidentally editing the VBA code?
I don't want to lock down the whole workbook where people can run macros but can't see the code.
I want to let others see the code but don't want them accidentally deleting something and break the program (something even I am prone to doing to my code).
Just go to Visual Basic, right click your module, select VBA Project Properties..., under protection tab, you can lock your VBA code with password.
Hope this help. ^^
If you want the code to be visible and executable, then you can't stop people from making changes to it.
You can however, stop them from saving those changes, by opening the workbook as read-only.
You can mark a workbook as read-only in the File Properties from within File Explorer. Or, if your workbook is opened via Automation, then you can specify read-only in the open method.

Way to capture double click to open file?

Is there a way to have an Excel macro to check what file I double clicked on to open.
When I open that file, the Add-Ins installed load first, then the file I clicked on loads. How can I write code inside one of my Add-Ins to check what the filename is that I am trying to open?
I tackled this by using 2 instances of Workbook_Open inside an excel Addin.
When a file is loaded, the addin starts up, and checks to see if there are any active workbooks. If there is none, then we wait a little bit and check again, looped as many times as you deem necessary, or until there is a valid workbook open. This makes sure your computer has time to load up the excel file. Once there is an active workbook, we process it to make sure it is not the workbook of the addin. If it is, then we exit our code. If it isn't then we Do Stuff.
I solved 2 of my questions on this site with the same code that can be found HERE
Note: I left out the parts where I Do Stuff... because really it's there to do anything you want with it. The code in the link just does what the previous paragraph describes.