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

Posted on 2013-10-31
Last Modified: 2013-11-07
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:= _
       .EnableOutlining = True
    End With

Open in new window

Hope this makes sense!
Question by:kazmdav
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 81

Accepted Solution

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


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

717 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