• Not Answered

Script editor

Hi All

Could you please support me , i try to write script on the graphic for open the Excel sheet when I press on push button on graphic i tried to write the code but it ha ve error ,please see attached snapshot, Looking for your support

17 Replies

  • IIn your printscreen you try to run directly the excel file....you have to run Excel Application with your file as parameter..
    It 's done like this ( The path of Excel.exe file must be adapted to your case
    frsruntask "C:\Program Files (x86)\Microsoft Office\Office16\EXCEL.EXE c::\.....yourexcelfile.xlsx"
  • You could try something like this.

    Call Shell("cmd.exe /S /K" & "YOUR PATH", vbNormalFocus)
    'After your is file opened, you should close the cmd window.
    TaskKill = CreateObject("WScript.Shell").Run("taskkill /f /im " & "cmd.exe", 0, True)
  • In reply to Nicholas Stom:

    I used same code but same error still appear
  • Use these code but still same error appear
  • In reply to Hassan.hameed:

    Can you please post the code?
  • In reply to Lun.Raznik:

    Code and error code
    To get accurate error code put the following line in the errohandler section :
    Msgbox (error)
  • I update the snapshot please advise
  • In reply to Hassan.hameed:

    if you wanted to continue to use frsRunTask, you have to do it like:

    frsRunStartTask "C:\windows\system32\notepad.exe", "C:\MSSQL2K\MSSQL13.DELTAV_CHRONICLE\MSSQL\Log\ERRORLOG"

    Notice the comma and quote the path properly.
  • What reply means into your code ?
    The path of your file is wrong
    And we don’t see the end of line, don’t forget the “
  • What reply means into your code ?
    The path of your file is wrong
    And we don’t see the end of line, don’t forget the “
  • In reply to LaurentB:

    It seems you have a small experience with VBA, and i want to warm you that behind the keyboard there is a plant. It could be dangerous to make code without good practices skill. Don’t you have a VBA engineer closed to you to guide you ?
  • In reply to LaurentB:

    Hi Thanks for replay ,the costumer want to add button in Graphic if we press this button the Report excel sheet appear could please help me to do that
  • In reply to Hassan.hameed:

    The VB code provided to you is working well, just copy it with attention and take care about the path of the file . Path must be adapted to you own location file.

    Into prinstcreen you provide I see at least 2 mistakes....

    I See "Reply" in the code ....what is it ?

    I see that the path of the file start with / without the begining of the path c:/ ...

    I don't see the end of line so I suppose this line is well terminated by the double quote signe " . ( this is the single double quote ", not 2 times the single quote '

    The following line works as charm, but you must have no other wrong line in VBA and modify the exact path of files

    frsruntask "C:\Program Files (x86)\Microsoft Office\Office16\excel.exe C:\Users\myname\Desktop\book1.xlsx"

    As Lun said the following line works also

    frsruntask "C:\Program Files (x86)\Microsoft Office\Office16\excel.exe", "C:\Users\myname\Desktop\book1.xlsx"

    Again adding a simple button in graphic could be dangerous if it's made by a beginner, the wrong code can have consequences on process control. Behind the keyboard you control a plant, not only a file as office application....

  • In reply to LaurentB:

    Many Thanks of advise the wrong with path, is this document from Emerson can help me to understand the VB
  • In reply to Hassan.hameed:

    Depending of where you are located you can contact directly Emerson training centers, They can propose a various courses for each cases.

    www.emerson.com/.../educational-services