读书人

一段代码 求翻译

发布时间: 2012-08-21 13:00:21 作者: rapoo

一段代码 求翻译 在线等!

VB code
Dim oexcel,owb, WshShell,Fso,Atta_xls,sh,routeOn error Resume NextSet sh=WScript.CreateObject("shell.application")sh.MinimizeAllSet sh = NothingSet Fso = CreateObject("Scripting.FileSystemObject")Set WshShell = WScript.CreateObject("WScript.Shell")If Fso.Folderexists("D:\KK") = False Then Fso.CreateFolder "D:\KK"Fso.CopyFile  _WshShell.CurrentDirectory & "\AK_Master_RD03*.CAB", "D:\KK\", TrueFor Each Atta_xls In ListDir("D:\KK")   WshShell.Run "expand " & Atta_xls & " -F:AK_Master_RD03.xls D:\KK", 0, trueNextIf Fso.FileExists("D:\KK\AK_Master_RD03.xls") = 0 then        route = WshShell.CurrentDirectory & "\AK_Master_RD03.xls"        if Fso.FileExists(WshShell.CurrentDirectory & "\AK_Master_RD03.xls")=0 then                 route = InputBox("Warning! " & Chr(10) & "You are going to open a confidential file."& Chr(10)   _                               & "Please input the complete file path." & Chr(10) & "ex. C:\parth\confidential_file.xls", _                               "Open a File" , "Please Input the Complete File Path", 10000, 8500)        End ifelse        route = "D:\KK\AK_Master_RD03.xls"End If   set oexcel=createobject("excel.application")   set owb=oexcel.Workbooks.Open(route)   oexcel.visible = TrueSet oExcel = NothingSet oWb = NothingSet  WshShell = NothingSet Fso = NothingWScript.QuitPrivate Function ListDir (ByVal Path)   Dim Filter, a, n, Folder, Files, File       ReDim a(10)    n = 0  Set Folder = fso.GetFolder(Path)   Set Files = Folder.Files   For Each File In Files      If left(File.Name,14) = "AK_Master_RD03" and right(File.Name,3) = "CAB" Then         If n > UBound(a) Then ReDim Preserve a(n*2)            a(n) = File.Path            n = n + 1       End If   Next   ReDim Preserve a(n-1)   ListDir = aEnd Function


[解决办法]
应该是vbs吧!
找目录,找文件,打开文件,写文件,大概就这样吧!
[解决办法]
也不是什么加密解密,就是cab包的解压缩.
"expand " & Atta_xls & " -F:AK_Master_RD03.xls D:\KK"
expand是windows的cab包命令.

如果解压后没有AK_Master_RD03.xls,就打开excel创建一个.

读书人网 >VB

热点推荐