How to remove vba (macro) button from newly saved excel sheet by vba codes?

SIARAM

New Member
Joined
Sep 29, 2015
Messages
5
Friends I have added a ‘Button 1’ to save as the file at another location by vba codes. It saves the file at required location but it shows the same ‘Button 1’ there also at the new saved file. I want it should not show this button in the new saved file. For example I created an excel sheet whose name is abc.xlsx and now this sheet is saved at m:\formats\xyz.xlsx by vba codes which are assigned to the ‘Button 1’ in sheet abc.xlsx. Now the same button i.e. ‘Button 1’ is shown in xyz.xlsx, but I want it should not be shown there. It should remain in the master file which is abc.xlsx. Kindly tell me what modifications I have to make in the codes. My codes are following-

HTML:
Sub sb_Copy_Save_ActiveSheet_As_Workbook()        Set wb = Workbooks.Add
    ThisWorkbook.Activate
    ActiveSheet.Copy Before:=wb.Sheets(1)
    wb.Activate     wb.SaveAs "C:\temp\test3.xlsx"End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Maybe:
Code:
Sub sb_Copy_Save_ActiveSheet_As_Workbook()
    Set wb = Workbooks.Add
    ThisWorkbook.Activate
    ActiveSheet.Copy Before:=wb.Sheets(1)
    wb.Activate
    ws.Shapes("CommandButton1").Delete
    wb.SaveAs "C:\temp\test3.xlsx"
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,076
Messages
6,128,669
Members
449,463
Latest member
Jojomen56

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top