PC Review


Reply
Thread Tools Rate Thread

disable a button

 
 
=?Utf-8?B?Q2FybGVl?=
Guest
Posts: n/a
 
      26th Apr 2007
Hi,

I use the following code to copy the worksheet selected in a listbox, to a
new workbook. Problem, this code copies a button on this worksheet, and i
don't want it to be copied. Can I prevent this?

the button on the sheet is called 'cmdMainMenu'

Private Sub cmdExport_Click()
Dim SH As Worksheet
Dim WB As Workbook
Dim WB2 As Workbook
Set WB = ThisWorkbook

WB.Sheets(Me.lstExportData.Value).Copy
Set WB2 = ActiveWorkbook

With WB2
.SaveAs Filename:=WB2.Sheets(1).Name & ".xls"
Call SendToDesktop(WB2)
.Close
End With
MsgBox "A copy of " & Me.lstExportData.Value & " has been pasted to your
desktop"

End Sub

--
Carlee
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      26th Apr 2007
Sheets(1).cmdMainMenu.Hide

"Carlee" wrote:

> Hi,
>
> I use the following code to copy the worksheet selected in a listbox, to a
> new workbook. Problem, this code copies a button on this worksheet, and i
> don't want it to be copied. Can I prevent this?
>
> the button on the sheet is called 'cmdMainMenu'
>
> Private Sub cmdExport_Click()
> Dim SH As Worksheet
> Dim WB As Workbook
> Dim WB2 As Workbook
> Set WB = ThisWorkbook
>
> WB.Sheets(Me.lstExportData.Value).Copy
> Set WB2 = ActiveWorkbook
>
> With WB2
> .SaveAs Filename:=WB2.Sheets(1).Name & ".xls"
> Call SendToDesktop(WB2)
> .Close
> End With
> MsgBox "A copy of " & Me.lstExportData.Value & " has been pasted to your
> desktop"
>
> End Sub
>
> --
> Carlee

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      26th Apr 2007
That probably should be Sheets(1).Controls.cmdMainMenu.Hide. Anyhow, hide
the button if you don't want to copy it.

"Carlee" wrote:

> Hi,
>
> I use the following code to copy the worksheet selected in a listbox, to a
> new workbook. Problem, this code copies a button on this worksheet, and i
> don't want it to be copied. Can I prevent this?
>
> the button on the sheet is called 'cmdMainMenu'
>
> Private Sub cmdExport_Click()
> Dim SH As Worksheet
> Dim WB As Workbook
> Dim WB2 As Workbook
> Set WB = ThisWorkbook
>
> WB.Sheets(Me.lstExportData.Value).Copy
> Set WB2 = ActiveWorkbook
>
> With WB2
> .SaveAs Filename:=WB2.Sheets(1).Name & ".xls"
> Call SendToDesktop(WB2)
> .Close
> End With
> MsgBox "A copy of " & Me.lstExportData.Value & " has been pasted to your
> desktop"
>
> End Sub
>
> --
> Carlee

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      26th Apr 2007
You might have to use the visible property with the button. I think hide
only applies to the user form.

CommandButton.visible = False

"Carlee" wrote:

> Hi,
>
> I use the following code to copy the worksheet selected in a listbox, to a
> new workbook. Problem, this code copies a button on this worksheet, and i
> don't want it to be copied. Can I prevent this?
>
> the button on the sheet is called 'cmdMainMenu'
>
> Private Sub cmdExport_Click()
> Dim SH As Worksheet
> Dim WB As Workbook
> Dim WB2 As Workbook
> Set WB = ThisWorkbook
>
> WB.Sheets(Me.lstExportData.Value).Copy
> Set WB2 = ActiveWorkbook
>
> With WB2
> .SaveAs Filename:=WB2.Sheets(1).Name & ".xls"
> Call SendToDesktop(WB2)
> .Close
> End With
> MsgBox "A copy of " & Me.lstExportData.Value & " has been pasted to your
> desktop"
>
> End Sub
>
> --
> Carlee

 
Reply With Quote
 
Norman Jones
Guest
Posts: n/a
 
      26th Apr 2007
Hi Carlee,

Try:

'=============>>
Private Sub cmdExport_Click()
Dim SH As Worksheet
Dim WB As Workbook
Dim WB2 As Workbook
Set WB = ThisWorkbook

WB.Sheets(Me.lstExportData.Value).Copy
Set WB2 = ActiveWorkbook

With WB2
.Sheets(1).OLEObjects("cmdMainMenu").Delete
.SaveAs Filename:=WB2.Sheets(1).Name & ".xls"
.Close
End With
MsgBox "A copy of " & Me.lstExportData.Value _
& " has been pasted to your desktop "
End Sub
'<<=============


---
Regards,
Norman


"Carlee" <(E-Mail Removed)> wrote in message
news:885A477B-FAF8-40BB-90B0-(E-Mail Removed)...
> Hi,
>
> I use the following code to copy the worksheet selected in a listbox, to a
> new workbook. Problem, this code copies a button on this worksheet, and i
> don't want it to be copied. Can I prevent this?
>
> the button on the sheet is called 'cmdMainMenu'
>
> Private Sub cmdExport_Click()
> Dim SH As Worksheet
> Dim WB As Workbook
> Dim WB2 As Workbook
> Set WB = ThisWorkbook
>
> WB.Sheets(Me.lstExportData.Value).Copy
> Set WB2 = ActiveWorkbook
>
> With WB2
> .SaveAs Filename:=WB2.Sheets(1).Name & ".xls"
> Call SendToDesktop(WB2)
> .Close
> End With
> MsgBox "A copy of " & Me.lstExportData.Value & " has been pasted to
> your
> desktop"
>
> End Sub
>
> --
> Carlee



 
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
disable lock button beside power button? =?Utf-8?B?Z2VvcmdlMQ==?= Windows Vista General Discussion 2 12th Jun 2007 09:18 PM
Which button event would work the best to disable the button. =?Utf-8?B?VmVybg==?= Microsoft C# .NET 5 6th May 2005 04:39 PM
Skin pocket pc, disable hardware buttons, disable start button Tizio Incognito Microsoft Dot NET Compact Framework 1 3rd Feb 2005 09:13 AM
HELP: how to add clientscript disable the button after click button ? Tee Microsoft ASP .NET 1 25th Feb 2004 07:21 AM
How to Disable a Button from the Button's Event Handler? Jay Chan Microsoft Access 3 12th Nov 2003 03:08 PM


Features
 

Advertising
 

Newsgroups
 


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