Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlink to a file

Status
Not open for further replies.

youwannawhat

Programmer
Oct 3, 2001
43
US
I have a request to provide a hyperlink from some fields on a form to an 'SOP' file located on the network. They want the users to be able to access this file if they have questions regarding data entry procedures during data entry.

I'm envisioning the same type of functionality that I've seen if you click on the label 'Entry Date' next to a date box on a form and a window opens explaining details about the field(format, purpose, etc).

Any guidance would be greatly appreciated.

Thanks,

Paul
 
Sounds like you want a help system. There are several cheap ways to do this, or you could implement a commercial help system.
Cheap way #1: Create a label and put a filetostr() in its click event to read a text file containing the SOP you want to display. Then Pop up a small form containing a textbox with populated with the contents of the string.
Cheap (and really ugly) way #2:
In the click event of the label, put the command:
run &quot;notepad.exe <filename.txt>&quot;
Cheap (and elegant) way #3: Use automation to invoke the word processor for the SOP document.
Only cheap way #1 gives you control over the placement of the SOP on the screen, but it requires the SOP to be in a text file.
HTH.
Mike Krausnick
 
1. Create a new method on your form. I'll call mine appLaunch

Put the following code into the new method:

Code:
PARAMETER tcOutFile,tcCmd  

IF PCOUNT() < 1
	MESSAGEBOX("You did not provide a filename.","AppLauch Method")
	RETURN
ENDIF	

IF PCOUNT() < 2
	tcCmd = "Open"
ENDIF	
	
tcCmd = PROPER(m.tcCmd)

* This code was originally located in Ken Levy's DBF2XML program so blame 
* Ken for the bugs :)

* API Call to communicate with an application based on the registered
* file-type.  
* For example: 
* On my computer txt is notepad; DOC is word

DECLARE INTEGER ShellExecute ;
	    IN SHELL32.DLL ;
	    INTEGER nWinHandle,;
	    STRING cOperation,;   
	    STRING cFileName,;
	    STRING cParameters,;
	    STRING cDirectory,;
	    INTEGER nShowWindow
	    
* tip: to determine commands available for each filetype
* Launch explorer
* go to View / Folder Options
* Select the File Type Tag	
* go to the item you wish to look up (example Acrobat)
* Press Edit
* You will see acrobat has Open, Print, and Printto option types.    
	
IF !FILE(tcOutFile) AND ATC("[URL unfurl="true"]WWW.",UPPER(tcOutFile))[/URL] = 0
	MESSAGEBOX(tcOutFile + " does not exist!","AppLauch Method -- AppLauch Method")
ELSE	

	* play with this.  
	* by adding the ,0 instead of ,1 I was able to get it to
	* print directly without opening the document on my sceen.
	
	
	* this is handy if you wish to print a pdf, word document, 
	* spreadsheet, text file, etc. from within your applicaiton.
	IF m.tcCmd = "Print"
		lnFileStatus = ShellExecute(0,"&tcCmd",tcOutFile,"","",0)
	ELSE
		lnFileStatus = ShellExecute(0,"&tcCmd",tcOutFile,"","",1)
	ENDIF	
	DO CASE 
	CASE m.lnFileStatus > 32
		* successful open
	CASE m.lnFileStatus = 2 
		MESSAGEBOX("Bad Association (for example, invalid URL)",;
			"AppLauch Method -- AppLauch Method")
	CASE m.lnFileStatus = 29
		MESSAGEBOX("Failure to load application","AppLauch Method -- AppLauch Method")
	CASE m.lnFileStatus = 30
		MESSAGEBOX("Application is busy","AppLauch Method -- AppLauch Method")
	CASE m.lnFileStatus = 31
		MESSAGEBOX("No application association with specified "+;
			"command: " + m.tcCmd,"AppLauch Method -- AppLauch Method")
	OTHERWISE
		MESSAGEBOX("Unknown Error","AppLauch Method -- AppLauch Method")
		RETURN .F.
	ENDCASE		
ENDIF

2. Put this in the click event of the text box, label, etc. that you wish to launch the file.

Code:
THISFORM.appLaunch("myfile.txt")

It at works with almost all file types (doc, text, pdf, xls, etc.) and URL (
Here is a url example:
Thisform.appLaunch("
Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top