Launching External Documents

K

Kent

Hi all,

This is probably a simple question for most, but I am not familiar with Java
Script at all. I'd like to add buttons throughout a number of my forms that
basically link to "help" documents. These might be Word docs, PDF files,
Windows Journal Notes templates, JPEGs, etc. It appears that I might be able
to do this by adding JS for each button. I have tried adding hyperlinks, but
InfoPath always adds the "http:\\" prior to my local file path, i.e. "C:\Help
Files\filename.pdf".

Can anyone please provide a good step by step, line by line instruction on
how to do this? I've searched the site here but can't seem to find any
previous posts that address this.

Thanks much in advance,

Kent in Anchorage
 
K

Kent

OK....I got Java Script that will indeed launch a word document from a button
click. I need to find out what I need to do to this so that I can launch:
Excel Workbooks (.xls), PDF documents (.pdf), Windows Journal Notes
(especially important)(.jnt), and JPEG images (.jpg).

Here's a sample script that works for launching a Word document with a
button click event:

{
var wd = new ActiveXObject("Word.Application");
wd.visible = true;

var wdDoc = wd.Documents.Open
("C:\\Demos\\Temp Folder\\Test of Launching a Word Doc.doc");

}


Any help with modifications to this that will make it work with these other
document types will be GREATLY appreciated.

Thanks,

Kent in Anchorage
 
S

S.Y.M. Wong-A-Ton

Try calling a command line from script to try opening the documents. E.g.,
you can do this for word by calling

Winword "C:\myword.doc"

from a command line. For PDFs the code would be as follows:

var wshShell = new ActiveXObject("WScript.Shell");
wshShell.Run("acrord32 C:\\Demos\\Temp Folder\\MyPDF.pdf");

Look into the "File Types" listed in Windows Explorer to find the names of
the other applications you need to call. If the program is registered on your
machine, it should be callable through script.
 
K

Kent

Thanks very much. I'll give this a try!

Kent

S.Y.M. Wong-A-Ton said:
Try calling a command line from script to try opening the documents. E.g.,
you can do this for word by calling

Winword "C:\myword.doc"

from a command line. For PDFs the code would be as follows:

var wshShell = new ActiveXObject("WScript.Shell");
wshShell.Run("acrord32 C:\\Demos\\Temp Folder\\MyPDF.pdf");

Look into the "File Types" listed in Windows Explorer to find the names of
the other applications you need to call. If the program is registered on your
machine, it should be callable through script.
 
P

Paul Mayer

Kent:

I designed a a form to hyperlink to the attachment. I added a hyperlink
data element and then dragged it onto the form. I then went in and edited
the hyperlink field by right clicking on the hyperlink feild and selecting a
edit hyperlink. In the datasource of the hyperlink properties in used the
concat function to build my location to the attachment I wanted to open.
Here is the my concat statement
Concat("\\ServerPath\",RecordNumber,".pdf)
It is best to use UNC naming conventions since if your users are in
different location they may not have the same drive letter mapped to the
directory where your help files are located. In my example, I use the record
number as part of the file name for my attachments, also make sure that the
server path name has a "\" at the end of it or it wont be able to find your
file because it will look like \\servernamefilename.pdf instead of
\\servername\filename.pdf once the string are concatenated together to create
the hyperlink to the file location and name. By putting the concat statement
in the hyperlinks properties it allow me to create a dymanic hyperlink which
changes to location based on the current record which has been selected.
 
P

Paul Mayer

Kent:

One additional thought about the server path. Make it a text string varable
so that if you move the files to a different UNC server location, you only
have to change once reference to the UNC location. Or have a data connection
to a file which has the information about the UNC location, filename and
extension store in the database. Add this dataconnection to each form you
use, then if you change the file location, you change it in the database once
and all of the InfoPath forms now point to the new location and it is totally
transparent to the user that the location of the hyperlink has changed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top