VBS operations Excel

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.