Can't find project or library - Reference option cannot be selected & modules are frozen - vba

I have this problem occur regularly with different workbooks. The file opens with:
Can't find project or library
I press Alt+F11 to open the VBA editor. I try clicking on References in the Tools menu but it doesn't do anything. I try editing the modules but I can't see any code and the windows are frozen. See attached file.

This is a guess, but sounds like there is a macro is running on 'open' of your spreadsheet, but the library it needs is missing (due to early binding, and a missing reference, often due to a different version of office).
Turn your macro settings to 'ask before running' - in office 265,
this is file-->options-->trust center-->trust center
settings-->macro settings-->disable all macros with notification.
reopen the file, but Don't enable the macro
press alt+f11 to enter the macro editor, then look at tools--> references for the
missing reference and try and fix.
Save and relaunch your spreadsheet, and enable macros

Related

Locked from viewing files not listed in VBE Project Explorer as before

After a fresh installation of Windows 11 I am unable to see some of my VB projects in the projects window. These projects were locked for viewing and had passwords set. I know the passwords.
Before the refresh, I could see them listed and was able to operate normally with them. Now, they just don't appear in the VBE Project Explorer. However, they do appear in the PowerPoint Add-in in the Developer tab.
Assuming that you mean you can see your add-ins listed in the VBA IDE:
Quit PPT if it's running.
Start REGEDIT
Locate:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\PowerPoint\Options
Under Options, add a new DWORD value named DebugAddins
Set its value to 1
Close REGEDIT, start PPT.

error "Macros is not available in this workbook or all macro may be disabled

I have developed an customized ribbon in excel and some macros using Visual Basics Script. Also, after completing when I send my excel to another computer along with add-ins I am getting error "Macros is not available in this workbook or macro may be disabled. Please be noted that I created add-ins and added the add-ins too but still I am getting this error. Kindly help me with this issue. Thank you.
In Excel, go to File > Options > Trust Center > Trust Center Settings > Macro Settings and select an appropriate setting to use.
Aside from what CLR wrote (and using the Excel file in the xlsm format), I noticed that if I run this VBS in a batch mode, it only gives me results if the batch is run "as an Administrator".

Excel 2013 - ActiveX warning despite allowing all ActiveX in Trust Center

I have an issue I'm struggling with, and it bothers me to no end. However, I can't come up with a decent solution, so I'm turning to you folks for advice.
The problem is as follows:
I have a .xlsm file containing a few macros. The macros use Forms, and specifically they also use TreeView objects in them (through mscomctl.ocx). I have gone through the Trust Center, and set every setting to it's unsafest form (allow all ActiveX, allow all VBA, no 'safe mode' for web documents, etc etc...
I can open the file, but when I call the macro relying on forms, I get a warning message labeled 'Microsoft Forms', with the following error message:
This application is about to initialize ActiveX Controls that might be
unsafe. If you trust the source of this document, select Yes and the
control will be initialized using your document settings.
It both surprises me (I said to allow it all in the settings, didn't I?) and annoys me (well, not the first time, but me and my coworkers use it on a daily basis and it gets on my nerves).
Does anyone have a clue whatsoever as to:
1) Why this happens?
2) How I can avoid the message?
I'm open to both solutions on altering the Excel file, or settings I have to alter on local machines (<20 PC's).
Details:
Windows 8.1, running Excel 2013. The macro-code is 'safe', it's built by our company employees (myself included). Code is password-protected so can't be meddled with.
Try the below steps
1) Launch Excel
2) Click "File - Options"
3) Click "Trust Center"
4) Select "ActiveX Settings"
5) Modify "ActiveX Settings for all Office Applications" from the default ("Prompt me..." - see above) to "Disable all controls without notification"
We see same error in an Excel solution with a TreeView form-component on 64-bit Win7 and solution here is to re-register mscomctl.ocx
Bat-file code:
regsvr32 /U "C:\Windows\SysWOW64\MSCOMCTL.OCX"
regsvr32 /S "C:\Windows\SysWOW64\MSCOMCTL.OCX"
Regards

Windows XP Excel VBA Crashes on Windows 7

I am trying to switch a Excel VBA macro from Windows XP to Windows 7. Both of the Windows versions are 32-bit operating systems. My Windows 7 version is Enterprise edition.
The VBA code works fine on Windows XP. When I have tried to run the code on Windows 7, it crashes and reports no error description.
I have registered msinet.ocx, which appears to be required for Microsoft Internet Transfer Control 6.0. I have also tried to fix security issues by adding the additional com components tabctl32, comctl332/232/32 and comdlg32, all of which are ocx files. However, nothing changes - my code still fails on Windows 7.
Once msinet was unregistered, Excel VBA opens my Workbook, reports the missing reference msinet and does not work at all. How do I resolve this issue?
Awkward. Open the sheet in an Excel session with Macro Security set to high or medium, and reply 'No' to the dialogue about enabling VBA macros in the sheet.
If it opens, you should still be able to view the project, and this might show an obvious missing reference or an error if you attempt to compile it.
Next: save the workbook as html and close Excel. Clear the temp folder, restart excel, open the html file and save it back into Excel format. If you're lucky, all the legacy objects and references will be cleared out and replaced by versions compatible with your new OS.
This works about half the time.
The system not crashing when msinet.ocx is not registered doesnt necessary means that it is the problem.
If you have a call to that library (msinet.ocx) in any procedure inside of or called from the ThisWorkbook module and you have that library unregistered, then when the file opens and tries to run the On open macro the module will not compile and therefore wont run the line of code that makes it crash. (I am only guessing that this might be your case.)
Try to find out which exact call makes your system crash.
Let msinet.ocx registered.
Open the file without activating the macros.
Then manually run Step by Step (F8) through the opening code of your file ( Private Sub Workbook_Open() )
Eventually you will reach the exact line of code that makes your system crash. Whit that information you will be able to get more help.
NOTE:
To open the file without activating the macros you can use one of the following methods:
Press and keep pressed the Shift key after you doubleclicked on the file to open it(from the windows explorer). For this method to work, the Excel application must be clossed.
If the Excel application is open, then go to the VB editor and type application.EnableEvents=False in the immediate window (and press enter to run it). Just be aware that this will disable the events on every file in that instance of Excel. You will have to set it back to true or close the application (not just the file).
Check if you don't have references to missing libraries, if so simply uncheck it. I had a similar problem and it helped in my case.

Where does Outlook store the VBA code files?

I had a VBA project in outlook with a few email macros - but after a PC crash they are all gone and all I see is a fresh 'Project1' when I hit Alt+F11
I'm not a VBA programmer, but had a collection of handy macros for email sorting etc. I would not like to have to code them again. Anyone know where the code files should be on the filesystem so that I might rescue the code?
This page has some really good insight on where Outlook keeps all its stuff. It suggests the following:
All Outlook macros are stored in a single file named VbaProject.otm in the user's %appdata%\Microsoft\Outlook folder, which will be a hidden folder on most systems.
Now, the problem is that if you do not see them now, then you probably won't be able to restore them from that location: there is probably either an "empty" project there or no project at all, but if that folder is being backed up, you might be able to restore it.
Moving forward, you might consider exporting your macros periodically in case this happens again, either through the VBA IDE (right-click and select Export File...) or using one of the tools mentioned in the linked article (like the Office Profile Wizard).
Ok. things to try to fix this...
I assume after the problem occured you tried logging back into the same windows user account, and the same Outlook profile.
Create a new windows login to the machine in question.
Login to this account and open Outlook, this will create a new outlook profile. make note of the profile name (to find this: Control Panel > Mail applet > Show Profiles...)
Now Exit Outlook, and make sure it is not running (check for outlook.exe in task manager).
Open Windows Explorer.
Copy (don't cut) the existing VbaProject.OTM file. (if it has any other name than that, first rename it to VbaProject.OTM, then copy).
Navigate to C:\Documents and Settings\USERNAME\Application Data\Microsoft\Outlook
(or use the environment variable notation %appdata%\Microsoft\Outlook for vista/win7)
Rename the existing VbaProject.OTM to VbaProject.OTM.OLD
Paste the VbaProject.OTM from step 5 into this folder.
Reopen Outlook and test (i.e. Alt + F11).
Good luck with recovery.
If this doesn't work do you remember adding self signing certificate at all? If so have you got a copy of the cert? you can try reinstalling it into the certificate manager (certmgr.msc)
copy/install it to the Certficiates - Current User\Personal\Certificates hive.
I just found this note from Sue Mosher (outlook VBA guru):
"AFAIK, once an .otm file is corrupted, it can't be recovered. That's why I recommend that people who rely on VBA code export their modules or backup the entire file. "
All macros are embedded into an OTM file, under the following location:
C:\Users\(***Your User Name***)\AppData\Roaming\Microsoft\Outlook\VbaProject.OTM
To restore, replace this file with the older one, it should work
Ran into this same problem.
First reviewed the .otm file mentioned by #Anonymous Type and #Dave DuPlantis
Not corrupted... hmm
I checked my Ribbon in Outlook for the Developer tab. It was missing and simply re-adding it to my Ribbon fixed my problem.