Protect VBA code excel without writing VBA code - excel

Sorry to bother you, i would like to stop people from being able to write code on VBA on my excel sheet.
But I can't do it since there is no VBA code already in place.
Then you will tell me to put some useless VBA code and protect it, but i can't do it because of workplace regulations (The document is approved as an excel sheet without vba).
So what do you think are my options ?
Is there a way to stop users from writing VBA code if you have no VBA code already written ?
If i use the project properties to add a password it won't work (because no vba code is written). I have tried this several times already
Thanks a lot,
Have a great day

Related

Excel Macro to find/replace in Sheets & VBA Modules

I am looking to write a macro to have in my Personal Macro Workbook that will be able to be activated and run a series of Find/Replace's both on the worksheets of any Spreadsheet I have open and within the VBA of any macros inside that spreadsheet. The worksheets part of this is easy, but I cannot find a way to do it to the Visual Basic Editor, and trying to record the macro seems to not pick up anything done in VBA. I do not care if the code is clever enough to go through every VBA module or it needs to go "module1", "module2" and so on and run the find/replaces for each module seperately (because I guarantee that none of them are named otherwise); but so far, I have not been able to find anything that works and does an automatic find/replace in Excel VBA.
If it helps as an example, I am looking to change any reference in the VBA of "" to "/"
Thanks
I have found something online about using VBINDE to change constants; but I haven't been able to modify it to change text as above.

How can we delete excel vba module when trying to see code

I have protected Excel VBA code with a password, which is breakable.
Now how can we delete that VBA module or code when trying to open that VBA code?
Thanks in advance.
The answer is: You just can't hide the code if someone breaks your password.
The issue is that anyone could start Excel with macros disabled. Then break your password and view your code. With macros disabled your deleting macro won't run too.
You cannot secure the code more than with that password. That's not possible.
The only secure way to hide code is not to include that code at VBA side:
What you can do to keep some algorithm code secret is creating a dll library (with any other language) that you then call from VBA. But that would only work for some functions like calculations but not for any code that interacts with worksheets. And the downside of this is that you would always need to give that dll along with your worksheet.

How to protect formulas in excel?

I have a workbook I have created with lots of different formula's. My question is, how can I stop the end user from stealing the formula's? I have had a look at: Protecting Code in an Excel Workbook?
This is generally for VBA. Is there a way to stop users doing this, or is it just worksheet protect and cross your fingers?
You probably should be more specific on what formulas are you trying to protect: Excel Worksheet formulas of the VBA code?
In general, you can create a custom VBA Add-in (i.e. .xla file) and protect it with password as per Excel documentation. In case your major concerns relate to worksheet function, then you can include them in said VBA add-in using for example, Range.Formula (re: https://msdn.microsoft.com/en-us/vba/excel-vba/articles/range-formula-property-excel ) or Range.FormulaArray properties.
Hope this may help.
There is no way to fully protect formulas in Excel. For every password protection type, there is a way to break that protection. The only thing you could do if you really wanted to prevent end-users from getting the formulas is to hard-code the entire sheet before sending it to them. Of course, if the workbook relies on user input and using formulas to output an answer, that won't work.
Do you need the formulas protected for some sort of IP reason, or just to prevent people from messing them up?

VBA and Excel running in parallel

This is a question that I have always had but never really gave it much though.
What I have at the moment is a worksheet that displays data, and the user refreshes whenever needed. So:
User triggers a VBA Function
VBA Function gathers data and analyses WHILE USER WAITS
VBA Function dumps the result on the spreadsheet
User continues viewing data
Since the data analysis is all done internally in VBA (No use of workbook, only recordsets, arrays, library etc.) I wanted to somehow be able to allow the user to continue viewing the original data, while VBA works on getting and analyzing new data.
I know you cant use the workbook AND run VBA at the same time, but you can however, have two excel instances and work on one workbook while the other runs VBA.
So could I somehow have my original excel instance call another excel instance and have it run the VBA while I work on my first instance?
Any Ideas?
(Also, not sure if the tag "Multithreading" is technically correct)
First thing - there is no multithreading for VBA in Excel.
Second thing - since Excel 2007, Excel supports multithreaded recalculation of formulas.
Therefore to approach multithreading calculations in Excel you can do at least 2 things:
Create a second instance of Excel (new Application instance! Not a new workbook within the same Application!) and execute the macro remotely.
Create UDF functions (User Defined Functions) in VBA. Unfortunately you cannot edit other cells using UDF but you can save the results of your computations in a Global variable and then print the results.
My recommendation - go with option 2.
I haven't been able to try this, but it seems like you can launch Excel from VBA using Application.FollowHyperLink. The hyperlink would have to be the local path to the sheet. You might have to use VBA to also make a copy of the sheet first.
Have you thought through the concurrency issues with having two copies?

Is it possible to put a custom GUI on top of an Excel spreadsheet?

A friend of mine has a very complex Excel spreadsheet with many formulas and lots of data that he uses for work. He wants to put a custom GUI on top of it and then wants to sell it to other people in his profession. Basically he wants to make some freestanding software out of his spreadsheet? Is there any way to put a custom GUI on top of an Excel spread sheet? The spreadsheet would just reside in the backend and be a kind of database and do the calculations necessary. I know this is definitely not an elegant solution but I told him I'd look into it. Any ideas?
I use Clear Office.
You can host workbooks in your GUI, host GUI in your workbook. All .NET, no interop.
Excel Interop fits the bill. Code your GUI with WinForms/WPF and .NET; invoke excel in the background to be your calculation engine. Pretty ugly (and probably slow) solution, though.
Check out the book Professional Excel Development by Bovey. It talks about how to do some radical Excel customizations along the lines of what you are suggesting.
Depending on how complex the application/input is, he may be able to use userforms, which are built in to Excel. Alternately, he can set up a sheet as in input form, and use other sheets for data/calculations, and super-hide them. We made a spreadsheet for a company at work, and used both solutions. Userforms can be frustratingly inflexible, but they work.
You can also add in some VBA to show the Userform when the workbook is opened, although if macros are disabled (which they are by default) then it won't work.

Resources