Solved

Excel VBA: Can I enable only one shape for inserting into a cell & disable all others

Posted on 2013-10-31
1
634 Views
Last Modified: 2013-11-07
Hi,
I would like the user to be able to insert only one shape inside a cell. Therefore, I'd like to disable all other shapes and/or objects. Preference for enabled shape would be something simple, eg; rectangle.

I don't think you need to know what VBA code I already have but here is an example for the workbook just in case:
 With Sheet1 'AO5 tech
       .Protect Password:="password", UserInterfaceOnly:=True, AllowFormattingCells:=True, AllowFormattingRows:=True, AllowInsertingHyperlinks:=True, DrawingObjects:=False, Contents:=True, Scenarios:= _
        True
       .EnableOutlining = True
    End With
    

Open in new window


Hope this makes sense!
0
Comment
Question by:kazmdav
1 Comment
 
LVL 80

Accepted Solution

by:
byundt earned 500 total points
ID: 39615778
If you set DrawingObjects:=True when you protect the worksheet, the user will not be able to insert a shape. But you can do so with a macro.
Sub Protector()
With Sheet1 'AO5 tech
       .Protect Password:="password", UserInterfaceOnly:=True, AllowFormattingCells:=True, AllowFormattingRows:=True, _
            AllowInsertingHyperlinks:=True, DrawingObjects:=True, Contents:=True, Scenarios:=True
       .EnableOutlining = True
    End With

End Sub

Sub NewShape()
ActiveSheet.Shapes.AddShape msoShapeRectangle, ActiveCell.Left, ActiveCell.Top, ActiveCell.Width * 0.9, ActiveCell.RowHeight * 0.9
End Sub

Open in new window

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now