VB6如何删除指定EXCEL工作簿的VBA工程?
如题,在VB6中如何编写代码删除指定EXCEL工作簿中的VBA工程(模块、类模块、窗体)?
Public Sub DelVbaProject(ByVal sFileName As String)'这里参数即是XLS文件的完整路径,如:c:\myapp\1.xls On Error Resume Next Dim xlsApp As New Excel.Application'需要在工程里引用EXCEL对象哦 Dim xlsWorkBook As Excel.Workbook Dim vbPro Set xlsWorkBook = xlsApp.Workbooks.Open(sFileName) Set vbPro = ActiveWorkbook.VBProject With vbPro For i = .VBComponents.Count To 1 Step -1 LCount = .VBComponents(i).CodeModule.CountOfLines .VBComponents(i).CodeModule.DeleteLines 1, LCount .VBComponents.Remove .VBComponents(i) Next i End With xlsWorkBook.Save xlsWorkBook.Close xlsApp.Quit End Sub