1

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
user692942
  • 16,398
  • 7
  • 76
  • 175
Vinay
  • 19
  • 1
  • 3
  • instead of using hard coded value i want to pass parameters dynamically while exectuion. So some one help me how to use the WScript.Auguments(0) statement – Vinay Apr 25 '17 at 13:42
  • Why the many beginner questions about vbscript this day ? it's a dying language you know ? – peter Apr 25 '17 at 14:02
  • 1
    Possible duplicate of [Using command line arguments in VBscript](http://stackoverflow.com/questions/2469754/using-command-line-arguments-in-vbscript) – user692942 Apr 25 '17 at 14:02
  • It's been covered just search and you will find. – user692942 Apr 25 '17 at 14:03

1 Answers1

0

It's Wscript.Arguments, not .Auguments

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

Wscript.Echo Wscript.arguments(0)
peter
  • 41,770
  • 5
  • 64
  • 108
  • It's [been covered](http://stackoverflow.com/a/22538644/692942). Also instead of pointing out typos, why not [edit the question](http://stackoverflow.com/posts/43612330/edit) and correct them? – user692942 Apr 25 '17 at 14:04
  • HI peter thank you so much for help. Actually tried to update value in excel using selenium code but while retriving after updating i am getting previuos value only from formula cell. so trying to update excel using vb script and fetch value. – Vinay Apr 25 '17 at 14:29
  • @Vinay shame you didn't search first. – user692942 Apr 25 '17 at 14:38
  • @Vinay, you'd better edit your question and tell us the current error, the object does not support this property/method:'WScript.Auguments' is what I responded on – peter Apr 25 '17 at 16:12
  • @ lankymart : Thanks for effort :) – Vinay Apr 26 '17 at 07:57
  • @peter this is a good example of why you should flag as a duplicate *(let's face it, this won't be the first time someone asked about passing arguments to VBScript)* and move on. – user692942 Apr 26 '17 at 08:00