Hello, I created a floating form and, on this form, I have a button to create a new tab/worksheet from a hidden tab. How can I disable the "+" button to create a new tab/worksheet so the user has to use my button?
Thanks,
Hello, I created a floating form and, on this form, I have a button to create a new tab/worksheet from a hidden tab. How can I disable the "+" button to create a new tab/worksheet so the user has to use my button?
Thanks,
You could protect the workbook, then have your code unprotect, add the sheet, then reprotect.
Rory
If you protect the structure of the workbook Review/Protect Workbook, the user will not be able to add a new sheet. On the other hand, you, in code, will have to programmatically remove the protection, insert a sheet from the "template" and put the workbook structure protection back on.
Artik
Ok thanks all, I'll give the protect/unprotect a try....
Ok I protected the workbook and am using the lock unlock to create the tab which works great BUT it took away the delete so I added a delete button to my form and use the DeleteActiveWorksheet sub which it works great as well.
The issue I have with the delete is I don't want it to never be able to delete a tab called "INFO" and a tab called "MAIN". how can I do that?
Please Login or Register to view this content.
Please Login or Register to view this content.
Change it to:
Please Login or Register to view this content.
Open Visual Basic for Applications (VBA) by pressing Alt+F11.
In the Project Explorer window, find your project and expand it.
Find the "ThisWorkbook" object (or whatever object you have VBA code in).
Double-click an object to open the code editor for that object.
Paste the following code into the code editor:
Private Sub Workbook_Open()
Application.CommandBars("Worksheet Menu Bar").Controls("Sheet Tabs").Enabled = False
End Sub
This code will run every time the workbook is opened and disable the New Tab/Sheet Plus button.
Save your changes and close the code editor.
Administrative Note:
Welcome to the forum.
We would very much like to help you with your query, however we recommend that you include code tags around your code.
Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.
Please see Forum Guideline #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks