Lparameters lpcFile2Treat,lpcMacro2Delete * if you don't need to use this on the regular basis just * remove the row with "lparameters" and assign your own file and macro names * explicitly If Empty(lpcFile2Treat) lpcFile2Treat="C:\JS_OLEAutomationBook\Excel_book.xls" Endif * this workbook has two macros with names "show_formats" and "show_sheets" If Empty(lpcMacro2Delete) lpcMacro2Delete="show_sheets" Endif Local ; loExcelApp As excel.Application, ; loVBProject As vbide.VBProject, ; loVBComponent As vbide.VBComponent loExcelApp =Createobject("Excel.Application") loExcelApp.Workbooks.Open(lpcFile2Treat) loVBProject=loExcelApp.ActiveWorkbook.VBProject For Each loComponent In loVBProject.VBComponents If loComponent.CodeModule.CountOfLines>0 If loComponent.CodeModule.ProcBodyLine(lpcMacro2Delete,0)>0 * inform user about current action ? loComponent.Name ? "You need to delete next " ?? loComponent.CodeModule.ProcCountLines(lpcMacro2Delete,0) ?? " lines" loComponent.CodeModule.DeleteLines(; loComponent.CodeModule.ProcStartLine(lpcMacro2Delete,0),; loComponent.CodeModule.ProcCountLines(lpcMacro2Delete,0); ) Endif Endif Endfor * now switch to Excel and press Alt+F11 * and observe the result loExcelApp.Visible=.T. Wait loExcelApp.Visible=.F. loExcelApp.Quit Release loExcelApp>Using automation I have populated an excel spreadsheet with a macro to create three charts. I did this just to see if it was easier than trying to "convert: the VBA code in VFP. Everything is working great, but now I want to DELETE those macros. Mainly because of security reasons -- I'd rather not have the user see the MACRO Warning message that pops up when they open up the newly create Excel file.