PC Review


Reply
Thread Tools Rate Thread

Delette active sheet from form button

 
 
TimSpangler
Guest
Posts: n/a
 
      9th Oct 2009
When I try to delete the active sheet with a button that I have on the
sheet I get an automation error. I assume it is because the button is
firing the event and I am trying to delete the sheet that the button
is on.

Is there a way to do this? Any help would be appreciated

Thanks

TIM
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      9th Oct 2009
Hi,

That wouldn't cause an automation error, the sheet & button are deleted.
What else do you have in the module, post the code.

Mike

"TimSpangler" wrote:

> When I try to delete the active sheet with a button that I have on the
> sheet I get an automation error. I assume it is because the button is
> firing the event and I am trying to delete the sheet that the button
> is on.
>
> Is there a way to do this? Any help would be appreciated
>
> Thanks
>
> TIM
>

 
Reply With Quote
 
TimSpangler
Guest
Posts: n/a
 
      9th Oct 2009
This is what I have in the button code:

' Sub to delete the current braced wall line
Private Sub CmdBtn_DELBWL_Click()

Application.DisplayAlerts = False
If ActiveSheet.Name = "MASTER" Then
MsgBox "MASTER Sheet can not be deleted", vbCritical, "BWL
Sheet Delete Error!"
Else
ActiveSheet.Delete
Application.DisplayAlerts = True
End If

End Sub

And when the button is selected I get this:

Run-time error '-2147221080 (800401a8)':

Automation Error



On Oct 9, 3:09*pm, Mike H <Mi...@discussions.microsoft.com> wrote:
> Hi,
>
> That wouldn't cause an automation error, the sheet & button are deleted.
> What else do you have in the module, post the code.
>
> Mike
>
>
>
> "TimSpangler" wrote:
> > When I try to delete the active sheet with a button that I have on the
> > sheet I get an automation error. *I assume it is because the button is
> > firing the event and I am trying to delete the sheet that the button
> > is on.

>
> > Is there a way to do this? *Any help would be appreciated

>
> > Thanks

>
> > TIM


 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      9th Oct 2009
Hi,


I can replicate this if the code is in a worksheet module.

Put the sub in a general module and don't declare as private and attach the
code to your button and things should be fine.

Mike


"TimSpangler" wrote:

> This is what I have in the button code:
>
> ' Sub to delete the current braced wall line
> Private Sub CmdBtn_DELBWL_Click()
>
> Application.DisplayAlerts = False
> If ActiveSheet.Name = "MASTER" Then
> MsgBox "MASTER Sheet can not be deleted", vbCritical, "BWL
> Sheet Delete Error!"
> Else
> ActiveSheet.Delete
> Application.DisplayAlerts = True
> End If
>
> End Sub
>
> And when the button is selected I get this:
>
> Run-time error '-2147221080 (800401a8)':
>
> Automation Error
>
>
>
> On Oct 9, 3:09 pm, Mike H <Mi...@discussions.microsoft.com> wrote:
> > Hi,
> >
> > That wouldn't cause an automation error, the sheet & button are deleted.
> > What else do you have in the module, post the code.
> >
> > Mike
> >
> >
> >
> > "TimSpangler" wrote:
> > > When I try to delete the active sheet with a button that I have on the
> > > sheet I get an automation error. I assume it is because the button is
> > > firing the event and I am trying to delete the sheet that the button
> > > is on.

> >
> > > Is there a way to do this? Any help would be appreciated

> >
> > > Thanks

> >
> > > TIM

>
>

 
Reply With Quote
 
TimSpangler
Guest
Posts: n/a
 
      9th Oct 2009
Will do. I'll try that and get back to you.

Thanks


On Oct 9, 3:51*pm, Mike H <Mi...@discussions.microsoft.com> wrote:
> Hi,
>
> I can replicate this if the code is in a worksheet module.
>
> Put the sub in a general module and don't declare as private and attach the
> code to your button and things should be fine.
>
> Mike
>
>
>
> "TimSpangler" wrote:
> > This is what I have in the button code:

>
> > ' Sub to delete the current braced wall line
> > Private Sub CmdBtn_DELBWL_Click()

>
> > * * Application.DisplayAlerts = False
> > * * If ActiveSheet.Name = "MASTER" Then
> > * * * * MsgBox "MASTER Sheet can not be deleted", vbCritical, "BWL
> > Sheet Delete Error!"
> > * * Else
> > * * * * ActiveSheet.Delete
> > * * * * Application.DisplayAlerts = True
> > * * End If

>
> > End Sub

>
> > And when the button is selected I get this:

>
> > Run-time error '-2147221080 (800401a8)':

>
> > Automation Error

>
> > On Oct 9, 3:09 pm, Mike H <Mi...@discussions.microsoft.com> wrote:
> > > Hi,

>
> > > That wouldn't cause an automation error, the sheet & button are deleted.
> > > What else do you have in the module, post the code.

>
> > > Mike

>
> > > "TimSpangler" wrote:
> > > > When I try to delete the active sheet with a button that I have on the
> > > > sheet I get an automation error. *I assume it is because the button is
> > > > firing the event and I am trying to delete the sheet that the button
> > > > is on.

>
> > > > Is there a way to do this? *Any help would be appreciated

>
> > > > Thanks

>
> > > > TIM


 
Reply With Quote
 
TimSpangler
Guest
Posts: n/a
 
      9th Oct 2009
OK. VB isn't really my thing, I am winging this right now. I took it
out of the worksheet and put it in the workbook but how do I get the
code attached to the button now? Do I us a Call from the worksheet
button event?



On Oct 9, 3:58*pm, TimSpangler <tim.spang...@gmail.com> wrote:
> Will do. *I'll try that and get back to you.
>
> Thanks
>
> On Oct 9, 3:51*pm, Mike H <Mi...@discussions.microsoft.com> wrote:
>
>
>
> > Hi,

>
> > I can replicate this if the code is in a worksheet module.

>
> > Put the sub in a general module and don't declare as private and attachthe
> > code to your button and things should be fine.

>
> > Mike

>
> > "TimSpangler" wrote:
> > > This is what I have in the button code:

>
> > > ' Sub to delete the current braced wall line
> > > Private Sub CmdBtn_DELBWL_Click()

>
> > > * * Application.DisplayAlerts = False
> > > * * If ActiveSheet.Name = "MASTER" Then
> > > * * * * MsgBox "MASTER Sheet can not be deleted", vbCritical,"BWL
> > > Sheet Delete Error!"
> > > * * Else
> > > * * * * ActiveSheet.Delete
> > > * * * * Application.DisplayAlerts = True
> > > * * End If

>
> > > End Sub

>
> > > And when the button is selected I get this:

>
> > > Run-time error '-2147221080 (800401a8)':

>
> > > Automation Error

>
> > > On Oct 9, 3:09 pm, Mike H <Mi...@discussions.microsoft.com> wrote:
> > > > Hi,

>
> > > > That wouldn't cause an automation error, the sheet & button are deleted.
> > > > What else do you have in the module, post the code.

>
> > > > Mike

>
> > > > "TimSpangler" wrote:
> > > > > When I try to delete the active sheet with a button that I have on the
> > > > > sheet I get an automation error. *I assume it is because the button is
> > > > > firing the event and I am trying to delete the sheet that the button
> > > > > is on.

>
> > > > > Is there a way to do this? *Any help would be appreciated

>
> > > > > Thanks

>
> > > > > TIM


 
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
Active sheet problem / macro button manfred3 Microsoft Excel Programming 0 15th Apr 2010 08:15 PM
save only active sheet Button. tim Microsoft Excel Misc 7 23rd May 2008 11:27 PM
'new record' button not active in Access 2007 form (old 2003 form) =?Utf-8?B?Q2hyaXMgU21pdGg=?= Microsoft Access Forms 2 26th Jun 2007 04:03 AM
Button on sheet: ? VB code to add date in active cell AA Arens Microsoft Excel Discussion 8 12th Dec 2006 10:06 PM
Copy my active sheet to a new sheet and open with an input form Brad Withrow Microsoft Excel Programming 0 6th Apr 2006 03:56 AM


Features
 

Advertising
 

Newsgroups
 


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