VBA Password Prompt shows on Exit from Excel - vba

I have been experiencing an issue where the VBA Password Prompt appears when exiting Excel for workbooks that have a locked VBA project.
For me it is happening on a Win10 / Excel2013 and Win10 / Excel2016 environment. I have searched for and tried a number of possible solutions. See the attached workbook and a step recorder that shows this happening for one of the tests. One interesting difference for the tests that are included to the workbook is in the case where a "pop-up" form is displayed, when closing the VBA password prompt is shown 5 times instead of 3 times on a standard exit from the workbook for the other tests.
Sample Workbook - https://sites.google.com/a/xlautomation.com.au/website/free-downloads/TestVBAPassword%20v2%20Share.xlsm?attredirects=0&d=1
Password to see the code in this workbook...."password"
Step Recorder showing the issue - https://sites.google.com/a/xlautomation.com.au/website/free-downloads/VBA%20Password%20Prompt%20Example.zip?attredirects=0&d=1
I can see from other posts that this problem has appeared over the years and some have resolved it with removing Add-In references, Closing Excel in a certain way none of these are working in my case. It is not a viable option to unprotect the VBA project as the workbooks are shared with others and allowing access to the code would present support issues.
If anyone has further suggestions to resolve this issue please share those back.
I have also include a demo of the issue in action below...

Could it be you have Dropbox installed on your system. A weird pointer to it solved my solution (short of making the Excel sheet into an xlam add-in) in no longer asking for the password:
right click on Dropbox symbol in system tray
Select the gear symbol (settings) at the right top
Select "Preferences"
In its "General"tab set "Show Dropbox Badge" to "Never show".
Click OK
That's it. How that affects Excel I don't know.

Related

Excel 2013 - User can't execute specific macro - File name listed before macro in Macros window

We have a single user unable to execute a specific macro in an XLSM file using Excel 2013. The issue seems to be tied to the user's entitlements because he gets the same error even on a freshly imaged machine. I would love to know if anyone has seen this issue before so we can pinpoint what's causing it internally. This can't be replicated by any other user, but is persistent to the user's account on any PC.
When he tries to execute a macro, nothing happens. No error message. Just nothing. On further review, the macro name looks weird in the macros window. It looks like (File Name).xlsm'!(Sheet Name).(Macro Name) instead of just listing the macro name. Screenshot here:
The macro is a public sub sitting on the sheet. If I move the code to a module, the name displays correctly and the macro runs, but that's not the way the code was designed to function. I'm not looking for help with the code. (This isn't mine to change and it works fine for dozens of users.) But I would be extremely grateful if someone familiar with this could give me an idea of what's happening here and perhaps why it could be tied to a user's corporate entitlements.
Thank you!

Corruption in Excel Workbook in 2016 but OK in 2010

I built an Excel workbook at a customer site, on their hardware, using Excel 2010. The workbook has an ActiveX button to execute macros to run a SQL stored procedure and populate a data sheet. I use the same code at all my customers. The workbook runs fine. I password protect the VBA to stop anyone changing the code.
I took my usual backup copies. When I open the workbook on my laptop, running Excel 2016, I get the
"we found a problem with some content..."
recovery message. If I recover, it removes the button and some of the VBA code.
I have tried amending my Trust Centre settings but no difference. When I VPN into the client, the workbook onsite opens OK. However, another external party has tried opening one of the workbooks using his local 2013 version and gets the same thing.
Apparently, the CFO uses Excel for Mac so I am wondering if this is causing an issue, or whether there is something screwy going on with the versions of Excel. I have created at least 12 workbooks, all using the same code, and they all behave in the same way.
Any suggestions would be greatly appreciated.
after advice from Dave yesterday, it appears that replacing my ActiveX Control with a Form Control has done the trick. I had to amend my macro code slightly as there is no onclick option for a Form button so I created a sub that calls my various VBA chunks which is then assigned to the button.
Thanks for all the responses and advice.

Excel giving "System Error &H80004005 (-2147467259). Unspecified error" message

Everytime I load up my Excel document, it repeatedly shows up with the message from the title. The two options are OK and Help. help opens Office Help which is useless for anything. Clicking OK displays another message saying "Compile error: Out of memory." with OK and Help buttons. Clicking OK brings up VBEditor with no debug line selected and no macro popped up either for that matter. Eventually, after it repeats that and complains 20 (exaggeration) more times (I think that's due to having a lot of duplicate code for ActiveX controls on each sheet). It highlights the first line (the Sub declaration) of the code below.
Private Sub ComboBox4_Change()
Range("B3") = ActiveSheet.ComboBox4.text
End Sub
Now this is dealing with an ActiveX ComboBox. Opening a file from an earlier date will give no errors. It's like after a certain date, it just refuses to work with it. And get this, it's only happening on one computer. The files are saved on a network drive, which shouldn't be causing an error.
I'm almost 100% certain I found a solution to this issue. It may have caused issues for someone else 4 years ago, but it caused issues for me today and I wanted to contribute my answer for anyone else running into the same problem.
I had enabled an "Additional Control" in the Controls Toolbox for Windows Media Player. I think when it loaded in a video file, it overran the memory. This is when I started panicking (company computer and all) and Googling and came across this and a few other articles without a real, fast fix.
The hunch: Once that video file was attempted to be loaded in RAM memory (because that's how Userforms work) it locked up all the memory Excel would allow before throwing all the errors.
What I tried from other posts in various places: I rebooted a few times (before Googling, even). I tried the Quick Repair of Office from Add/Remove programs, that didn't work. (I'm using Office 2016.)
So, what worked? I had the idea that maybe I could disable all ActiveX from loading in my file, and Googled that. I got: https://support.office.com/en-us/article/enable-or-disable-activex-settings-in-office-files-f1303e08-a3f8-41c5-a17e-b0b8898743ed and proceeded to disable all ActiveX controls in Excel. I closed the file out. Can't recall if I closed Excel but I probably did.
Then I loaded up my file. (ActiveX is totally disabled at this time.) No errors! I went to VBA (ALT + F11), opened my UserForm, and the video I had inserted and could not remove was just... gone. I saved the file. I closed the file.
I opened Excel. I re-enabled ActiveX in the Trust Center. I opened my file. Still, no more video on my UserForm (I didn't need it anyway) and no "Unspecified" (memory) errors! And, I can save again!
I hope this solution persists... if not I've got some "splainin' " to do. So far, I'm designing and using the Userform, and saving the file, with no issues whatsoever. I think it worked!
I believe the problem was that I had a user form with an acrobat reader display control (like an iframe, but for PDFs). I didn't have this reference or control on that specific computer and it freaked out. Not 100% sure, but the problem no longer exists.
I have been having a very similar problem with WindowsMediaPlayer (WMP) ActiveX control that I have in a Form. Some computers with office 2016 are giving this error code (usless the help button), this is the first post I have found about something similar with WMP, and I found it after searching for this error on ActiveX controls...
So my solution was to go to VBA (alt+F11), right clic on form that has the activex control and then remove it witohout exporting.
The big problem is, that for me, this form is the most important part of the application.
I have no mor information, if I find something I'll come back to post feedback.
I encountered this issue when trying to pull data from an access database. The query I was trying to pull from in the database was an all value query (*). Once I added the individual fields, the error went away.
I've got this error, when I create a user form which has no body section(just header). (Using this method for the messages where I don't expect a user response. Like a progress bar.
Probably, any abnormality(*)or inconsistency with the user form causes this problem.
Solution: Changed the height of the user form just a few pixel.
Just a simple trick worked for me
Go to Excel Options
Manage Excel Add-ins
Uncheck all and click ok

Macro not responding on different computer

I have a macro which works fine on my computer when I click its button but it does not work on different computers.
All the macros on that excel file are not working when clicking on the button.
However, I have a macro working before saving. That means that when I try to save, another macro works properly. (that macro pop up an input message, but is not relevant now). So it seems that macros are not working only when you call them by a click...
The version of Excel is the same one and I enabled the macro when asked.
It is not a problem of the code because even if I create a new simple macro on that file from the different PC (such as:
msgbox("hello")
) it is still not responding.
I had a problem with that excel file in the past and I had to manually delete all the *.exd extensions in my computer. However once I deleted those extensions, the file worked well.
I believe that the excel file is considered corrupted by other computers and they do not enable the macro. This is just my impression but I cannot get why the macro is working when saving and not working when clicking.
Do you have any idea to solve the problem?
I had issues like that myself both with macros and with Excel workbook doing some really funny stuff (like formulas not calculating properly, or functions not working as expected etc) and I did not find any other solution then copying the content of the file and pasting into a newly created file.
In each case this resolved my problem.
It suggests that my files somehow got corrupted and the only solution was to save the contents and delete the files.
Exporting the .frm and .frx files from VBEditor (Modules and Forms) worked fine for me.
Have you tried this yourself?
This may be too simple a suggestion, but have you checked the security settings in Excel? The other computers may be set to a higher security setting that disables all macros without notifying the user.
https://support.office.com/en-US/Article/Enable-or-disable-macros-in-Office-documents-7b4fdd2e-174f-47e2-9611-9efe4f860b12?ui=en-US

XLAM / XLA Addins: is there a better way?

This post is about installing XLAM's without creating links. (Everyone hates links). Consider the trivial addin:
Public Function UDF_HELLO(x)
UDF_HELLO = "Hello " & x
End Function
Put this code and nothing else into a Module and save as "Hello.xlam" on the Desktop (and NOT in the default excel addins folder). Next, while HELLO.XLAM is still open, create a new XLSX workbook with the formula
=UDF_Hello("world")
in cell A1, which simply displays "Hello world" in that cell. Save the workbook and exit Excel. Now, if you reopen the workbook without the XLAM, Excel will complain about "links to other sources ...". Whether you click "Update" or "Don't Update", Excel will mangle the formula in cell A1 like this:
='C:\Documents and Settings\tpascale\Desktop\Hello.xlam'!UDF_Hello("world")
Very often this "forced-linkage" is NOT desirable. In my computing environment there is a lot of ad-hoc analysis and it makes no sense to impose an install regimen on every XLAM we throw together to solve the problem of the day. I just want to hand out XLAM files to users and let those users open them when they need them, WITHOUT having to worry about the slightest mis-step causing their formulas to get mangled.
QUESTION:
Is there a way to instruct Excel to NEVER construct external links for UDFs, and simply to use UDFs if they're loaded and return #VALUEs otherwise ?
I don't know of a way around this with .xla/.xlam add-ins.
But this issue does not occur with .xll add-ins.
These can be created in C using the Excel 2010 SDK, or in managed languages like VB.NET or C# using the free Excel-DNA library.
(Disclaimer: I'm the developer of Excel-DNA. This issue is one of the reasons I went with the .xll interface for making managed UDF add-ins.)
You can have them open the .xla file and have an Auto_Open procedure install the add-in.
http://www.vbaexpress.com/kb/getarticle.php?kb_id=693
After excel closes you can have the add-in uninstall itself.
oAddIn.Installed = False
You can give your add-in a setting for the user to not uninstall after every use by using a worksheet named something then have cell A1 equal to true or false.
I haven't tested this but hopefully it works for you.
This should work to resolve your issue though it does not instruct Excel regarding external links. I have tested it myself by creating the XLAM, saving it to my desktop, installing it in the Excel add-ins and then using it on a new workbook.
Steps:
Once you have saved the add-in, close it.
Go to Excel Options-->Add-Ins
In the Manage drop-down select Excel Add-ins and press 'Go'
In the 'Add-Ins'dialogue that appears click 'Browse' and navigate to
the add-in you just created. Select it and hit 'Ok'
If prompted to save the add-in in the add-ins folder, select 'No'.
Selecting 'Yes' may cause an error if the add-in file suffix does
not match the version of Excel being used.
Your add-in should appear in the 'Add-Ins available' scrollbox,
check its box and hit 'Ok'
Your add-in should now be active whenever you open Excel.
Test this by opening a new workbook and try using your UDF.
Best,
I usually solve this problem by:
Saving an XLA/XLAM file (outside Personal folder, of course)
Connect to it in Tools - Addins
Write pseudo macros in your current Excel file that links to those macros / functions in the XLA/XLAM file.
See the detailed instructions in my reply here.