Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 25th, 2012, 03:56 PM
Authorized User
 
Join Date: Sep 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBA to create and delete shapes

I am trying to create two buttons with VBA and then delete the two buttons. I need a way to create by name and then delete it by name. The below code will create the shapes but I get an error when trying to delete the shapes.

Code:
        'Add Buttons
        Set Firstbutton = ActiveSheet.Shapes.AddShape(5, 275, 945, 110, 25)
        Set Secondbutton = ActiveSheet.Shapes.AddShape(5, 390, 945, 110, 25)
        
        'Remove Buttons
        'ActiveSheet.Shapes(ASFbutton).Delete
        'ActiveSheet.Shapes(SBFbutton).Delete

Last edited by jbburf; September 25th, 2012 at 04:55 PM..
 
Old September 25th, 2012, 05:57 PM
Authorized User
 
Join Date: Sep 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It looks like I have answered my own question. I found that I can use the following code to delete the shapes:

Code:
        'Remove Buttons
        ASFbutton.Delete
        SBFbutton.Delete





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create XML File, Email it, Delete It timeware ASP.NET 2.0 Professional 4 December 22nd, 2009 08:08 AM
delete a user form using vba sms Access VBA 2 June 27th, 2008 07:15 AM
Re : shapes on Excel VBA forms Steve Spies Excel VBA 0 July 23rd, 2007 05:56 PM
Access VBA Delete Query Issue... snoopy92211 Access VBA 4 June 24th, 2004 03:57 PM
Create / Delete Active Directory Users Kilian Pro VB 6 0 June 12th, 2003 09:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.