I have a excel report that has VBA code written.When i try to view code, alongwith my code that is under display a new project VBAproject(Book 1) opens.Using this new workbook code can be written that changes my values in excel.I cannot set Userinterfaceonly to false as this doesnt allow the internal VBA to run.
Can the VBAproject(book 1) that opens alongwith my code under display be prevented/locked so that no new code can be written?
You can set a password on VBA associated with a workbook.
Open the VBA editor for the workbook you want to protect. Select the project, and go to the Tools Menu, then the VBAProject Properties option. Clicki the Protection tab, and set the password, confirm it, click OK. Save the workbook.
Now if you try to open the VBA for that workbook you'll be prompted for the password, but the VBA can still be called.
PS Don't forget the password!
Related
I am learning EXCEL vba and was trying to create a macro that ran when EXCEL was opened. It was saved as "Personal Workbook" and now every EXCEL spreadsheet I open has this macro. Should have selected as "This Workbook". How do I get rid of that macro so that Workbooks open without it.
Thanks
The personal workbook will be in Appdata/Microsoft/Excel/XLSTART. Just remove it from there. To get to your app data folder press windows+r and type %appdata%
If you just want to remove the module in Personal workbook that was created, rather than the whole file:
In the Visual Basic Editor (Alt + F11 to open)
Find the PERSONAL.XLSB VBA Project in the Project Explorer (Ctrl + R to open in the VBE)
Press the little + sign next to VBAProject.
Press the little + sign next to the Modules folder in the project.
Find the module containing the code, right-click the module and select Remove ModuleName
Using the gui to get to the file.
In Excel
File -> Options
Click on "Customize Ribbon"
In the right hand pain there is a "Developer" checkbox that is unchecked by default, check it.
Now go to the "Developer" ribbon and click "Macros"
Click the macro you do not want an click "Delete".
I have Workbook named Test. And in The Test I have code that runs when the workbook is opened it shows me UserForm1 which asks me to login with username and password and it will hide applications so only the UserForm1 is seen. The problem is that you can open Excel again and open a new workbook, and there you can go to the VBA and see workbook Test's code and close or modify it.
If the login would be requested in the input box, you can not do the trick and circumvent the login part. Input Box allows you only click in the workbooks Input Box you can't press ALT + F11 and go to VBA code or if you try to open new Workbook and in there goto VBA code there wouldn't be the Test's code. How to do this, with the UserForm?
Thank you so much for all your help in advance!
If it helps I can copy the code to do this , but it's a little mess.
What you want to do is protect your project, then auto execute your macro.
To protect you project do the following:
In your Project Viewer, right click your project then under the protection tab insert your password. You will then need to insert the password when you want to access your script for each instance you have the document open.
I have a workbook that contains several (lookup) tabs that I don't want any users to be able to unhide. However, there is one tab that contains admin info that I would like admin users to be able to see. I have a button and macro that prompts for an admin password before unhiding this tab, but if I protect the workbook structure (so that hidden tabs are not accessible for other users) the vba fails. Is there no way to protect/unprotect the workbook from within the admin macro? I have tried various combinations of ActiveWorkbook.Unprotect, ActiveWorkbook.Protect and ActiveWorkbook.ProtectStructure to no avail - both within the admin macro and WorkbookOpen. The error msg I most commonly encounter is "Can't assign to read-only property" even after having ActiveWorkbook.Unprotect at the top of my code. Does anyone know how to work around this? I don't really want to have to leave all tabs open to being unhidden with a second password on the Admin worksheet itself - clumsy!
Instead of protecting the whole workbook, set the Visible property of the sheets you want to hide to xlSheetVeryHidden - you can do this manually in the properties window of the VBA editor. Now those sheets won't show up in the Unhide… dialog. Your macro could swap the visibility of your admin-only sheet from xlSheetVeryHidden to xlSheetVisible and back.
By itself this doesn't protect your workbook from a user who knows how to access the VBA editor and properties, but if you need to do that there seem to be a lot of answers to a quick web search - it may depend on your version of Excel.
By mistake I wrote code that will close the workbook when it is opened.
Because of this I am unable to see the code in order to fix it. How do I edit the code?
open Excel, go in and disable macros from the Trust Center, then open your workbook and remove the offending line of code.
http://office.microsoft.com/en-gb/excel-help/enable-or-disable-macros-in-office-documents-HA010031071.aspx
Try opening some workbook and click alt + F11 to see the macro window. Then open your workbook and it should be ok.
Alternatively, try switching off the macros in Excel so that no macros could run. Then open your workbook.
Stated simply my question is as follows Is it possible for a button on a worksheet in a normal excel workbook (.xlsx not .xlsm) to trigger a macro in another file specifically an installed excel add in (.xlam).
Here is some background on why I want to achieve this. I have a workbook that many users need to be able to view but only some need to be able to update by filling in a form on another sheet and calling a macro in an add in. The worksheet should not contain any macros to avoid security warnings when opened by normal users. I can do this by having a ribbon button in the add in that the user clicks which will then check that the correct workbook is open and that the form is filled in etc. before executing the update code. However the interface would be nicer if the button instead of appearing on the ribbon was on the worksheet just below the form. Therefore my question is it possible to trigger an external macro from a button click in a non macro enabled workbook.
Yes, you can assign an external macro (which should be .xlsm file) to a non-macro-enabled workbook (.xlsx) button. My xlsm macro resides in the same directory as the xlsx workbook for simplicity. (Note: I am using Excel 2010)
Firstly, you must open your xlsm macro in the same instance of Excel window (i.e. do not open a new instance of Excel) so that your xlsx workbook will be able to see/access it.
Right-click on your xlsx workbook button and select "Assign Macro..."
Make sure you select Macros in: All Open Workbooks
All macros in open workbooks will be shown (this is why it is important to do step 1).
Select the desired macro from the list then click OK.
I don't see how you can execute a macro from a control in a non-macro-enabled workbook.