[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


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

Posted on 2013-10-31
Medium Priority
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 2000 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

Industry Leaders: 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.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
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…

649 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