Scripting

  • 1.  I am trying to display an image equal to the Sales

    Posted 09-14-2016 12:10
    I am trying to display an image equal to the Sales Order No using a button script added to the Sales Order Header tab and trying to use a simple script received from Alnoor long ago, but I'm having issues. The current version of the button script looks like this: Set WSHShell = CreateObject(""WScript.Shell"") Set FSO = CreateObject(""Scripting.FileSystemObject"") DrawingFile = SO_SalesOrder_bus_SalesOrderNo + "".png"" WSHShell.CurrentDirectory = ""Q:\Sage 100 Advanced 2016\MAS90\MAS_DBP\Signatures\Sales Order\"" If FSO.FileExists(DrawingFile) Then WSHShell.Run DrawingFile Else strMsg = ""Signature not found"" End If Set WSHShell = Nothing Set FSO = Nothing When I don't pass the SalesOrderNo field, I get my ""signature not found"" message box, but when I do pass it, I get an error that states ""OLE Error -2147023741. Script Line 38, Column 4"" which is equal to this line: WSHShell.Run DrawingFile What could be wrong with this Run command? Isn't ""DrawingFile"" defined correctly?


  • 2.  RE: I am trying to display an image equal to the Sales

    Posted 09-14-2016 12:17
    What happens when you just double-click on the file referenced by ""DrawingFile""? Does it display? Are you running on the server or on the client? On many servers, the Windows OS does not know what to do with a PNG file, which would cause your shell command to fail.


  • 3.  RE: I am trying to display an image equal to the Sales

    Posted 09-14-2016 12:19
    @PhilipWhirley makes a good point... I was wondering how you 'run' an image file myself, but I guess it makes sense if the extension is registered and Windows knows what to use to open the file.


  • 4.  RE: I am trying to display an image equal to the Sales

    Posted 09-14-2016 12:20
    Also make sure your button script is set to run on the workstation, not the server.


  • 5.  RE: I am trying to display an image equal to the Sales

    Posted 09-14-2016 12:22
    I'm testing from the server, but I do have ""Execute script on client"" selected. When double-clicking the PNG file itself, it will open in Paint fine. I just changed the script to read "".jpg"" and saved a copy of the image as JPEG, but it still gives me the same error.


  • 6.  RE: I am trying to display an image equal to the Sales

    Posted 09-14-2016 12:29
    Could it be a 32-bit / 64-bit issue? Double-clicking will be in 64-bit mode, but the script will be 32-bit...


  • 7.  RE: I am trying to display an image equal to the Sales

    Posted 09-14-2016 13:01
    Maybe force the user to use Paint? WSHShell.Run(""c:\windows\system32\mspaint.exe"" & "" "" & DrawingFile)


  • 8.  RE: I am trying to display an image equal to the Sales

    Posted 09-14-2016 13:02
      |   view attached
    (Tested fine for me on 2016 Standard, Win7 64-bit, with a hard-coded file name).


  • 9.  RE: I am trying to display an image equal to the Sales

    Posted 09-14-2016 13:06
    External Access checkbox?


  • 10.  RE: I am trying to display an image equal to the Sales

    Posted 09-14-2016 13:08
    Steve's force suggestion worked! Now we'll see if it works at the client level. Thank you to everyone for chipping in, and Steve, I am saving this tip!