W
wyjch78
Unregistered / Unconfirmed
GUEST, unregistred user!
看到介绍
CM := WBk.VBProject.VBComponents.Item('ThisWorkbook').Codemodule;
{ Insert the macro text }
LineNo:=1;
CM.InsertLines(LineNo + 1, 'Public Sub Macro2');
CM.InsertLines(LineNo + 2, 'Dim xlApp As Excel.Application');
CM.InsertLines(LineNo + 3, 'Dim xlBook As Excel.Workbook');
CM.InsertLines(LineNo + 4, 'Dim xlSheet As Excel.Worksheet');
CM.InsertLines(LineNo + 5, 'Dim i, j As Integer');
CM.InsertLines(LineNo + 6, 'Set xlApp = CreateObject("Excel.Application"');
CM.InsertLines(LineNo + 7, 'Set xlBook = xlApp.Workbooks.Add("D:/Work/1.xls"');
CM.InsertLines(LineNo + 8, 'Set xlSheet = xlBook.Worksheets(1)');
CM.InsertLines(LineNo + 9, 'For i = 1 To xlSheet.UsedRange.Rows.Count');
CM.InsertLines(LineNo + 10, 'Cells.Replace What:=xlSheet.Cells.Item(i, 1), Replacement:=xlSheet.Cells.Item(i, 2), LookAt:=xlPart, _');
CM.InsertLines(LineNo + 11, 'SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,ReplaceFormat:=False');
CM.InsertLines(LineNo + 12, 'Next i');
CM.InsertLines(LineNo + 13, 'End Sub');
但是我的CM := WBk.VBProject.VBComponents后面就没有这个item的,是不是我uses里面缺少了什么东西啊。我加了个VBID2000也还是不行。请问是什么原因?
CM := WBk.VBProject.VBComponents.Item('ThisWorkbook').Codemodule;
{ Insert the macro text }
LineNo:=1;
CM.InsertLines(LineNo + 1, 'Public Sub Macro2');
CM.InsertLines(LineNo + 2, 'Dim xlApp As Excel.Application');
CM.InsertLines(LineNo + 3, 'Dim xlBook As Excel.Workbook');
CM.InsertLines(LineNo + 4, 'Dim xlSheet As Excel.Worksheet');
CM.InsertLines(LineNo + 5, 'Dim i, j As Integer');
CM.InsertLines(LineNo + 6, 'Set xlApp = CreateObject("Excel.Application"');
CM.InsertLines(LineNo + 7, 'Set xlBook = xlApp.Workbooks.Add("D:/Work/1.xls"');
CM.InsertLines(LineNo + 8, 'Set xlSheet = xlBook.Worksheets(1)');
CM.InsertLines(LineNo + 9, 'For i = 1 To xlSheet.UsedRange.Rows.Count');
CM.InsertLines(LineNo + 10, 'Cells.Replace What:=xlSheet.Cells.Item(i, 1), Replacement:=xlSheet.Cells.Item(i, 2), LookAt:=xlPart, _');
CM.InsertLines(LineNo + 11, 'SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,ReplaceFormat:=False');
CM.InsertLines(LineNo + 12, 'Next i');
CM.InsertLines(LineNo + 13, 'End Sub');
但是我的CM := WBk.VBProject.VBComponents后面就没有这个item的,是不是我uses里面缺少了什么东西啊。我加了个VBID2000也还是不行。请问是什么原因?