PC Review


Reply
Thread Tools Rate Thread

Automating key strokes to a dialog box

 
 
Scott G
Guest
Posts: n/a
 
      6th Nov 2006
I am running a simple macro where I need to delete a worksheet named
"Pivot", using the following code in VBA:

Sheets("Pivot").Delete

However, when I run this, I get a dialog box within Excel that reads:

"Data may exist in the sheet(s) selected for deletion. To permanently
delete the data, press delete"

The dialog box has two buttons "Delete" (which is active) and "Cancel".

Is there a way that I can automate the pressing of the delete button so
that the end user doesn't have to respond to the dialog box?

Thanks in advance.

 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      6th Nov 2006
Set the DisplayAlerts to False before you do the delete, then restore it to
true after the delete. E.g.,

Application.DisplayAlerts = False
Sheets("Pivot").Delete
Application.DisplayAlerts = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)


"Scott G" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am running a simple macro where I need to delete a worksheet named
> "Pivot", using the following code in VBA:
>
> Sheets("Pivot").Delete
>
> However, when I run this, I get a dialog box within Excel that reads:
>
> "Data may exist in the sheet(s) selected for deletion. To permanently
> delete the data, press delete"
>
> The dialog box has two buttons "Delete" (which is active) and "Cancel".
>
> Is there a way that I can automate the pressing of the delete button so
> that the end user doesn't have to respond to the dialog box?
>
> Thanks in advance.
>



 
Reply With Quote
 
Scott G
Guest
Posts: n/a
 
      6th Nov 2006
Thanks Chip, that worked perfectly!


Chip Pearson wrote:
> Set the DisplayAlerts to False before you do the delete, then restore it to
> true after the delete. E.g.,
>
> Application.DisplayAlerts = False
> Sheets("Pivot").Delete
> Application.DisplayAlerts = True
>
>
> --
> Cordially,
> Chip Pearson
> Microsoft MVP - Excel
> www.cpearson.com
> (email address is on the web site)
>
>
> "Scott G" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I am running a simple macro where I need to delete a worksheet named
> > "Pivot", using the following code in VBA:
> >
> > Sheets("Pivot").Delete
> >
> > However, when I run this, I get a dialog box within Excel that reads:
> >
> > "Data may exist in the sheet(s) selected for deletion. To permanently
> > delete the data, press delete"
> >
> > The dialog box has two buttons "Delete" (which is active) and "Cancel".
> >
> > Is there a way that I can automate the pressing of the delete button so
> > that the end user doesn't have to respond to the dialog box?
> >
> > Thanks in advance.
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automating Opening Of "Help and Support Center" Dialog? (PeteCresswell) Windows XP General 1 4th Sep 2007 04:52 PM
Automating a dialog box via VB sendKeys and SetTimer Bob Stark Microsoft Powerpoint 0 27th Jun 2004 11:03 AM
Re: File Open dialog box when automating import Roger Carlson Microsoft Access External Data 0 10th May 2004 06:47 PM
Automating dialog with web server from VB.NET Mark Gross Microsoft VB .NET 16 5th May 2004 03:57 AM
automating key strokes Faye Smith Windows XP Customization 1 19th Oct 2003 09:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:38 PM.