Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy workbook containing macro to a workbook without macro

Tags:

excel

vba

I am able to duplicate a workbook (copy to a desired location) which contains a macro in the background. This duplicate copy also contains the same macro. My Problem is I do not want this duplicate workbook to have a macro with it. Can anyone tell how to do it?

Thank you in advance!!!

like image 444
Kaushik Datye Avatar asked Jan 29 '13 13:01

Kaushik Datye


People also ask

How do you copy Excel macro from one workbook to another?

Open both the workbook that contains the macro you want to copy, and the workbook where you want to copy it. On the Developer tab, click Visual Basic to open the Visual Basic Editor. , or press CTRL+R . In the Project Explorer pane, drag the module containing the macro you want to copy to the destination workbook.

How do I save an existing macro to a personal workbook?

On the Developer tab, click Record Macro. In the Record Macro dialog box, type a meaningful name for the macro in the Macro name box. Make sure you don't use any spaces in the name. In the Store macro in box, select Personal Macro Workbook.


1 Answers

Save your workbook as macro-free, i.e. simply as Excel Workbook. For my Excel 2007 this is done using:

Application.DisplayAlerts = False
ThisWorkbook.CheckCompatibility = False
ThisWorkbook.SaveAs Filename:="D:\DOCUMENTS\Book1.xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Application.DisplayAlerts = True

Correct path & name as you wish.

Read more about SaveAs method: http://msdn.microsoft.com/en-us/library/office/ff841185%28v=office.14%29.aspx ...and available File Formats: http://msdn.microsoft.com/en-us/library/office/ff198017%28v=office.14%29.aspx

Hope that was helpful)

like image 177
Peter L. Avatar answered Oct 25 '22 14:10

Peter L.