locked
Getting VB script issue on Task Scheduler "Run whether user logged on or not". RRS feed

  • Question

  • I have a vb script. It reads text file and creates word document.  Script is as below. 

    I have scheduled job in Task Scheduler.

    • When I select "Run only when user logged on", then it script runs successfully and create output as expected. 
    • When I select "Run whether user logged on or not", then script creates error as below. 
      D:\ADDS\vbscript.vbs(6, 1) Microsoft Word: The document name or path is not valid.(D:\ADDS\MYFILE.TXT)

    D: is local drive here. 

    dim objwd
    dim mytest
    set objwd = wscript.createobject("word.application")
    objwd.visible=false
    objwd.documents.add
    objwd.selection.insertfile "D:\ADDS\ZCHECK_LOG.TMP","", false, false, false
    With objwd.ActiveDocument.PageSetup
    .Orientation = 1
    .PageWidth = "11"
    .PageHeight = "8.5"
    .TopMargin = "1.5"
    .BottomMargin = "1"
    .LeftMargin = "1"
    .RightMargin = "1"
    End With
    objwd.Selection.WholeStory
    With objwd.Selection.Font
    .Name = "Courier New"
    .Size = "7.5"
    .Bold = true
    End With
    objwd.activedocument.fields.unlink
    objwd.selection.endkey
    objwd.selection.delete 1
    objwd.activedocument.showgrammaticalerrors = false
    objwd.activedocument.showspellingerrors = false
    objwd.activedocument.saveas "D:\ADDS\ZCHECKLOG_20180730160001.DOC"
    objwd.documents.close
    objwd.application.normaltemplate.saved = true
    objwd.application.quit
    

    Monday, July 30, 2018 8:37 PM

All replies

  • Edit:

    ERROR is as below:

    D:\ADDS\vbscript.vbs(6, 1) Microsoft Word: The document name or path is not valid.(D:\ADDS\ZCHECK_LOG.TMP)


    Monday, July 30, 2018 9:00 PM