Problem opening a PDF with script

SUGGESTED

HI All,

     I am going in circles on this one.   I have several versions of this running on other systems with no problem.    It opens a PDF it it exists from PO Receipt History inquiry.   It is on Sage 100 2016 Advanced. It is running on Server 2012 R2.    It is a button script & is passed the Receipt no. Variable.  It is set to run on the server.  The company is set for external access (they have other scripts that work just fine)   The client saves the vendor packing slips using the receipt no. to the folder specified.   

The issue is that if the file exists, nothing happens.  It doesn't lock up.  If the file doesn't exist, I get the msgbox that it doesn't exist.   I have tested pasting the strfilepath into the run box in Sage and it opens the pdf.    I am baffled.  I have tried a number versions based on reading vb sites but nothing works.

Dim sh
Dim strFilePath
sRecNo = PO_ReceiptHistory_bus_ReceiptNo


strFilePath ="\\acctsage\DocScan\PackList\" &sRecNo& ".pdf"

Set sh = CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FileExists(strFilePath) Then
Set sh = CreateObject("Wscript.Shell")
sh.Run strFilePath
Set sh = Nothing
Else

sMsg = "file "& sRecNo &".pdf not found!"
retMsg = oSession.AsObject(oSession.UI).MessageBox(sMsg)
End If


Set fso = Nothing

Bob Osborn

Parents
  • 0
    I would assume that the vbscipt cannot open the program you have for displaying pdf files. Probably a permissions issue. And vbscipt wouldn't be my first choice to actually do much anyways... here is what I would do:

    Make a console application that displays itself (and waits for a sendkeys - or displays a message box). If that works, you know your pathing is right and there are no permission issues. Move it around for testing. Then make that console app open the pdf file. A console application can be given permissions your vbscipt may not have...
  • 0 in reply to Kent Rhodes
    If your script is set to run on the server then that's where the PDF would be launched. The MessageBox (an advanced scripting method) displays on the client because that's how it works -- even when run on the server. You don't need to use advanced scripting to do this. Rather set the script to run on the client and replace the MessageBox with MsgBox.
Reply
  • 0 in reply to Kent Rhodes
    If your script is set to run on the server then that's where the PDF would be launched. The MessageBox (an advanced scripting method) displays on the client because that's how it works -- even when run on the server. You don't need to use advanced scripting to do this. Rather set the script to run on the client and replace the MessageBox with MsgBox.
Children