HEScript to open Microsoft Word problems

I built and distributed a simple php application that opens Microsoft Word files that I have saved in an external location. A while ago, I found some info on the forum that offered the following code:

procedure OpenWord(FolderName: String);
var
EbookPath, MyFolder: String;
begin
EbookPath := GetGlobalVar("HEPublicationPath", "");
MyFolder := EbookPath + FolderName + "\";
OpenFile(MyFolder, "", SW_SHOWNORMAL);            
End;    

And the html:

<a href="hescript://UserMain.OpenWord|Word%20Files\Instructions.doc" class="button">Instructions</a>  

This code will open the external Word file and keep the original filename. It works great on Windows 7 most of the time; however, there are a few Windows 7 users that cannot open the Word files from this link. I’ve checked to make sure the folder containing the files is in the correct place and that there’s no firewall/antivirus issue preventing it from opening. It simply does not open. Has anybody else experienced this? I’m using version 1.5

Try to replace with:

procedure OpenWord(FolderName: String);
var
EbookPath, MyFolder: String;
i: integer;
begin
EbookPath := GetGlobalVar("HEPublicationPath", "");
MyFolder := EbookPath + FolderName + "\";
i := OpenFile(MyFolder, "", SW_SHOWNORMAL);      
if i < 32 then ShowMessage("Error launching file: " + inttostr(i));     
End;

Thank you for the reply. This seems to work on most computers, but on some machines people are receiving an error message (Error launching file: 5) when they click on a link to open a Word file. Is there any particular reason some computers would not want to open the Word files? I have double checked to make sure the Word files are in the proper place and that there aren’t any firewall issues.

Thanks again.

Error code 5 means access denied so some third-party program (like antivirus/antispyware) may block the Word file?