• VBS 去除文件夹下 Excel 的公式


    注意问题

    1. window 环境下运行, 代码 ANSI 编码格式保存。
    2. 直接放到需要转换的文件夹下,双击运行。

    代码

    
    function getfolder() 
    	getfolder=left(wscript.scriptfullname,instrrev(wscript.scriptfullname,"")-1) 
    end function 
    
    Call ShowFileList(getfolder())
    
    Sub ShowFileList(folderspec)
        Dim fs, f, f1, fc, s, objExcel, tmpname, sourcefile, dstfile, shell, tip
    		
        set objExcel = CreateObject("Excel.application")
        set fs = CreateObject("Scripting.FileSystemObject")
        set f = fs.GetFolder(folderspec)
        set fc = f.Files
    	set shell = CreateObject("WScript.Shell")
    
    	fs.createFolder("tmp")
    	
        For Each f1 in fc		
    		tmpname = f1.name
    					
    		if lcase(right(tmpname, 4)) = "xlsx" then     	
    				
    		sourcefile = folderspec + "" + f1.name
    		dstfile =  folderspec + "	mp" + tmpname
    		
    		set xslworkbook = objExcel.Workbooks.Open(sourcefile)
    		  			  					 
            For i = 1 to xslworkbook.Sheets.Count
    			  set UseRange1 = xslworkbook.Worksheets(i).UsedRange
    				  UseRange1.Copy
    				  UseRange1.PasteSpecial(-4163)
            next
    		
    		xslworkbook.SaveAs(dstfile)		
            xslworkbook.close()    		 
    		    
    		tip = tmpname + " complete ..."
    		
    		WScript.Echo tip
            end if 
        Next    
    		
    	objExcel.close
    	fs.close
    End Sub
    

    VBScript

    1. 用户手册
    2. 在线手册
    3. 语言参考
    4. 微软官方
    5. 函数
  • 相关阅读:
    python day09
    python day08
    python day07
    python day06
    python day05
    Django-Form组件之字段
    python装饰器
    npm常用命令
    python常用模块-re 正则表达式
    Django-forms效验组件
  • 原文地址:https://www.cnblogs.com/jingjingdidunhe/p/11281278.html
Copyright © 2020-2023  润新知