简体   繁体   中英

How to use Arguments in VBScript

I want to pass arguments in to my .vbs file and use them. So I did some research I tried to use WshSheel.Auguments statement. But while executing through command prompt it is giving me an error message

object does not support this property/method:'WScript.Auguments'

Dim objExcel, strExcelPath, objSheet

'strValue=WScript.Auguments(0)
'arrValue=Split(strValue,"|")
Set WshSheel = CreateObject("WScript.Shell")
strExcelPath ="C:\Users\Z997710\Desktop\pension1.xlsx"

' Open specified spreadsheet and select the first worksheet.
Set objExcel = CreateObject("Excel.Application")
objExcel.WorkBooks.Open strExcelPath
Set objSheet = objExcel.ActiveWorkbook.Worksheets(3)

' Modify a cell.

'objSheet.Cells(2, 1).Value =20
objSheet.Cells(2, 1).Value =WScript.Auguments(0)
objSheet.Cells(2, 2).Value ="09/02/2015"
objSheet.Cells(2, 3).Value ="09/02/2020"
'objSheet.Cells(2, 1).Value =Trim(arrValue(0))
'objSheet.Cells(2, 2).Value =Trim(arrValue(0))

strValue=objSheet.Cells(12, 4).Value

objSheet.Cells(12, 5).Value = strValue
msgbox strValue

' Save and quit.`enter code here`
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
'WScript.Quit

It's Wscript.Arguments, not .Auguments

Try this one line script in a console window with one parameter

Wscript.Echo Wscript.arguments(0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM