您的位置:程序门 -> vb -> vba



关于excel使宏无效的方法


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


关于excel使宏无效的方法
发表于:2007-03-09 11:01:31 楼主
一个有宏的excel(a.xls)处理后,想另存为其它的文件(b.xls),这样想让(b.xls)在打开后不需要做宏的处理(使宏无效),谁能告诉一下处理的方法。谢谢
发表于:2007-03-09 11:14:311楼 得分:0
打开b.xls,按下   alt+f8,然后把所有的宏一个个删掉咯
发表于:2007-03-12 14:33:322楼 得分:0
打开文件时不启用宏就可以了。
发表于:2007-03-18 19:01:383楼 得分:0
用一段vba代码在你另存文件时删除另存文件中的代码。
发表于:2007-03-18 19:08:354楼 得分:0
private   sub   commandbutton1_click()
    dim   objvbc   as   object
    dim   objmdl   as   object
    dim   arr()   as   variant
    dim   intcounter   as   integer
    dim   txt   as   string
     
    redim   arr(1   to   3,   1   to   activeworkbook.vbproject.vbcomponents.count)
    intcounter   =   0
   
    for   each   objvbc   in   activeworkbook.vbproject.vbcomponents
            set   objmdl   =   objvbc.codemodule       '引用單無內的程式碼
            intcounter   =   intcounter   +   1
            arr(1,   intcounter)   =   objvbc.type
            arr(2,   intcounter)   =   objvbc.name
            if   objmdl.countoflines   >   0   then
                  txt   =   objvbc.codemodule.lines(1,   objmdl.countoflines)
            end   if
               
            arr(3,   intcounter)   =   txt
            select   case   arr(1,   intcounter)
            case   1             'module
                      activeworkbook.vbproject.vbcomponents.remove   objvbc
            case   2             'class1
                      activeworkbook.vbproject.vbcomponents.remove   objvbc
            case   3,   100   'userform   or   thisworkbook
                      objvbc.codemodule.deletelines   1,   objmdl.countoflines
                      doevents
            end   select
    next   objvbc
end   sub



快速检索

最新资讯
热门点击