Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default disable a button

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" wrote in message
...
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
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 do you disable the Collate button? Trixie Excel Discussion (Misc queries) 0 August 25th 06 04:00 PM
Disable command button Mikeice[_22_] Excel Programming 2 June 17th 05 10:17 AM
Disable Button Pete JM[_3_] Excel Programming 2 April 12th 04 01:04 PM
how do you disable a button? jest[_4_] Excel Programming 1 March 4th 04 01:05 PM
Disable Button Pete[_12_] Excel Programming 3 October 8th 03 01:30 PM


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

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

About Us

"It's about Microsoft Excel"