有个小错误,代码名也是可以在程序中修改的 Sub ChageWksObjectName() Dim ws As Worksheet Dim sPrevCodeName As String Dim sNewCodeName As String '设置新对象的名称 sNewCodeName = "ws_main" '增加新工作表 Set ws = Worksheets.Add '获取新增工作表的对象名称 sPrevCodeName = ws.CodeName '变化新增工作表的对象名称 ThisWorkbook.VBProject.VBComponents(sPrevCodeName). _ Properties("_CodeName") = sNewCodeName End Sub ‘- - - - - - - - - - - - - - - - - - - - - - Sub Test() ws_main.Range("A1").Value = "This is it!" End Sub
[此贴子已经被作者于2010-11-12 22:51:24编辑过] |