Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Worksheet Delete method's dialog box

The Microsoft documentation states that the delete method for a
worksheet object issues a boolean False if a user clicks Cancel on the
dialog box that gets generated warning that data may be lost if the
worksheet is deleted. How can the return value from this dialog box
be examined in VBA? I get compile errors when I try examine
worksheetname.Delete directly.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Worksheet Delete method's dialog box

So you are deleting a sheet through code. When the code executes the user
confirmation dialog shows and the user decides whether to delete the sheet or
not.

After this is complete why not just check for the existence of the sheet
with a function something like this...

Public Function SheetExists(SName As String, _
Optional ByVal Wb As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If Wb Is Nothing Then Set Wb = ThisWorkbook
SheetExists = CBool(Len(Wb.Sheets(SName).Name))
End Function
--
HTH...

Jim Thomlinson


"xlmaven" wrote:

The Microsoft documentation states that the delete method for a
worksheet object issues a boolean False if a user clicks Cancel on the
dialog box that gets generated warning that data may be lost if the
worksheet is deleted. How can the return value from this dialog box
be examined in VBA? I get compile errors when I try examine
worksheetname.Delete directly.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Worksheet Delete method's dialog box

On Mar 28, 11:24*am, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
So you are deleting a sheet through code. When the code executes the user
confirmation dialog shows and the user decides whether to delete the sheet or
not.

After this is complete why not just check for the existence of the sheet
with a function something like this...

Public Function SheetExists(SName As String, _
* * * * * * * * * * *Optional ByVal Wb As Workbook) As Boolean
'Chip Pearson
* * On Error Resume Next
* * If Wb Is Nothing Then Set Wb = ThisWorkbook
* * SheetExists = CBool(Len(Wb.Sheets(SName).Name))
End Function
--
HTH...

Jim Thomlinson



"xlmaven" wrote:
The Microsoft documentation states that the delete method for a
worksheet object issues a boolean False if a user clicks Cancel on the
dialog box that gets generated warning that data may be lost if the
worksheet is deleted. *How can the return value from this dialog box
be examined in VBA? *I get compile errors when I try examine
worksheetname.Delete directly.- Hide quoted text -


- Show quoted text -


Jim,

Thanks for your reply. My concern is more fundamental--I am just
curious about how to get at the boolean value that the documentation
states is returned by the delete method.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Worksheet Delete method's dialog box

Since you do not directly spawn the dialog you would need to get a handle to
it somehow. IMO that is more work than it's worth.
--
HTH...

Jim Thomlinson


"xlmaven" wrote:

On Mar 28, 11:24 am, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
So you are deleting a sheet through code. When the code executes the user
confirmation dialog shows and the user decides whether to delete the sheet or
not.

After this is complete why not just check for the existence of the sheet
with a function something like this...

Public Function SheetExists(SName As String, _
Optional ByVal Wb As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If Wb Is Nothing Then Set Wb = ThisWorkbook
SheetExists = CBool(Len(Wb.Sheets(SName).Name))
End Function
--
HTH...

Jim Thomlinson



"xlmaven" wrote:
The Microsoft documentation states that the delete method for a
worksheet object issues a boolean False if a user clicks Cancel on the
dialog box that gets generated warning that data may be lost if the
worksheet is deleted. How can the return value from this dialog box
be examined in VBA? I get compile errors when I try examine
worksheetname.Delete directly.- Hide quoted text -


- Show quoted text -


Jim,

Thanks for your reply. My concern is more fundamental--I am just
curious about how to get at the boolean value that the documentation
states is returned by the delete method.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete the "Insert Function Dialog Box" (dialog box only)? TBI''d biker Excel Worksheet Functions 2 April 7th 07 09:18 PM
How to delete Excel worksheet using VBA without delete dialog? cocalico22 Excel Programming 4 September 15th 06 10:34 PM
Delete worksheet - dialog box showing Rick A[_2_] Excel Programming 1 May 24th 06 04:21 PM
Delete a Sheet without dialog Ken Loomis Excel Programming 4 March 24th 05 11:25 PM
Disable Worksheet Delete Dialog Greg Excel Programming 1 March 1st 05 08:32 PM


All times are GMT +1. The time now is 07:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"