Space Gold tax system upgrade, the export of Excel file format and the original difference, the old data import program can not recognize the file, compared with the old and new documents, found that the new file in the ticket and the "number of copies" line before the row added a row, while adding the "Document Number" column, through the script to delete these.
1Setnewformat ("C:\Users\gukajie\Desktop\ VAT Special Invoice data export 20150619.xls")2 3 Functionsetnewformat (filename)4 DimEx, Wb, Sht5 DimLastRow, R6 DimName37 SetEx =CreateObject("Excel.Application")8 SetWb =Ex.Workbooks.Open ((filename))9 SetSht = Wb.sheets ("Sheet1")Ten 'Delete lines 2nd through 5th One 'sht.rows ("2:5"). Delete ALastRow =Sht.UsedRange.Rows.Count - 'MsgBox lastrow - forR =2 toLastRowStep 1 theName =sht.range ("A"&R). Value -Name2 =sht.range ("J"& (R1)). Value - If( Left(Name,2)="Number of copies" andName2="") Then -Sht.rows (R1). Delete + 'MsgBox R - End If + A If(r=6) Then atName3 =sht.range ("H"& (6)). Value - End If - - Next - - If(name3="Document Number") Then inSht.columns (8). Delete - End If to + - Ex.ActiveWorkbook.Save the 'MsgBox "Operation Complete" * Ex.quit $ End Function
However, after the script is added to the Windows scheduled task, it is found to be unable to execute, and there will be a wscript.exe and Excel32.exe process in the first run process. In fact, the script executes
Set Ex = CreateObject ("Excel.Application")
After that, no more execution.
Google a bit, found
CreateObject ("Excel.Application")
Interactive requirements are required, and scripts that have interaction requirements cannot be run directly in Scheduled tasks.
This can only be performed if the user is logged on, so the scheduled task attribute needs to be checked:
VBS action Excel