ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   commandbutton removal (https://www.excelbanter.com/excel-programming/399093-commandbutton-removal.html)

Kip

commandbutton removal
 
Please help,

When i do a saveas and sendmail; the new file contains the original command
button and the macro associated with the button, I want to remove to button
in the newly copied file during the saveas function. Any ideas?

FSt1

commandbutton removal
 
hi
you problem comes from the saveas that you are doing. this saves the file
under a different name along with the data , controls, macros and all else.
what you need to do is just save the range of data to a new workbook and
email that.
how?
paste this in a standard module. you can fire it from a worksheet button or
a toolbar icon.
Sub mac1SaveRange()

'Macro written by FSt1 4/27/00

Dim cnt As Long
Dim cell As Range
On Error GoTo err1

MsgBox "You have selected range" & Selection.Address
If Selection.Cells.Count = 1 Then
If MsgBox("You have selected only one cell. Continue?", vbYesNo,
"Warning") = vbNo Then
Exit Sub
End If
End If
cnt = 0
For Each cell In Selection
If Not IsEmpty(cell) Then
cnt = cnt + 1
End If
Next
If cnt = 0 Then
If MsgBox("There is no data in the selected range. Continue?!?!?!?!?",
vbYesNo, "Warning") = vbNo Then
Exit Sub
End If
End If
'ActiveSheet.UsedRange.Select
Selection.Copy
Workbooks.Add
Range("A1").PasteSpecial xlPasteAll
Application.Dialogs(xlDialogSaveAs).Show
err1:
MsgBox ("Need a range to save.")
Exit Sub
End Sub

Post back if you have questions
Regards
FSt1
"Kip" wrote:

Please help,

When i do a saveas and sendmail; the new file contains the original command
button and the macro associated with the button, I want to remove to button
in the newly copied file during the saveas function. Any ideas?



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com