我得到了一个很好的脚本部分,从这里我不知道从哪里开始。
在下面的脚本中,我打开一个文件移动列并将文件保存在一个新文件夹中,并在其前面加上日期和时间。
我想做的是将这些列复制到一个新文件
我不介意改变这个脚本的方式我可以完全改变它
Set objArgs = WScript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")
For I = 0 to objArgs.Count - 1
CmplName = Year(Now()) & Month(Now()) & Day(Now()) & "H" & Hour(Now()) & "_"
FullName = objArgs(I)
FileName = Left(objArgs(I), InstrRev(objArgs(I), ".") )
RdyPath = "OrReady"
FNPathLen = InstrRev(FullName, "\")
FNLen = Len(FullName)
SNLen = FNLen-FNPathLen
ShortFullName = Right(FullName, SNLen)
ShortFileName = Left(ShortFullName, InstrRev(ShortFullName, ".") )
AdSavPath = Left(FullName, FNPathLen) & RdyPath & "\"
If fso.FolderExists(AdSavPath) Then
Else
fso.CreateFolder(AdSavPath)
End If
Set objExcel = CreateObject("Excel.application")
set objExcelBook = objExcel.Workbooks.Open(FullName)
objExcel.application.visible=false
objExcel.application.displayalerts=false
Set Cols = objExcel.Range("C1","C100000")
Set TCols = objExcel.Range("R1","R100000")
Cols.Cut
TCols.Insert
Set Cols = objExcel.Range("B1","B100000")
Set TCols = objExcel.Range("F1","F100000")
Cols.Cut
TCols.Insert
NewFile = AdSavPath & CmplName & ShortFileName & "xlsx"
objExcel.Workbooks(ShortFullName).SaveAs _
AdSavPath & CmplName & ShortFileName & "xlsx", 51
objExcel.Application.Quit
objExcel.Quit
Set objExcel = Nothing
set objExcelBook = Nothing
If fso.FileExists(NewFile) Then
MsgBox NewFile & " Exist Original File will be deleted => " & FullName
fso.DeleteFile(FullName)
Else
MsgBox " File Was Not Created "& NewFile & " (Did not Exist) Did not Delete Original File"
End If
Next