Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 25th, 2012, 03:56 PM
Authorized User
Points: 43, Level: 1
Points: 43, Level: 1 Points: 43, Level: 1 Points: 43, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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..
Reply With Quote
  #2 (permalink)  
Old September 25th, 2012, 05:57 PM
Authorized User
Points: 43, Level: 1
Points: 43, Level: 1 Points: 43, Level: 1 Points: 43, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:14 AM.


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