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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

facility to link a word/excel type document in a database

Status
Not open for further replies.
Jul 4, 2002
17
0
0
GB
All

I have created a screen and database for a simple application. I want the user to be able to link a file to the record.

They click on the screen and it allows them to select the file or at least they type in the path.

Can anyone help - we have just got new bosses and they want this working

MIS type bloke

Thanks
 
dean,
not fully clear, but
may be you want simply use getfile() ?
Tesar
 
I appreciate the responses given - thanks. I have taken a minute to explain my exact requirements.

I have a screen that the users go into and can create a new record in a database and add data to it. One of the fields is a gen field and I want them to be able to link a file to that field from within the screen ie they click on say a button and it gives them a chance to select a file from the network and save in/the link in the database.

If anyone what's a copy of the screen to see what I have so far they are welcome.

I really need this to work because we have new owners and it is a 'pet' project.
 
Dean,
with example for .txt files (in my 2.0):

* to choose file
*
! cd yournetpath
myfile = getfile("txt","Choose file and ESC..")
! cd yourlocalpath
* remember sufficient field size for fullpath file name !!!
* (or reduce it to 8.3)
repl mydbf.filname with myfile
...
* to use file, for example:
modi file (mydbf.filname) noed

Tesar



 
i used DDE (dynamic data exchange) to achieve this by just saving the path of the file in a field of a record, then opening a dde channel. thru that channel, you can send whatever command to the application (like word or excel). here is an old code i got from my vault, works only with word doc but can be modified if desired:

Code:
*************************************************
procedure sample_dde
	parameter anyfile, filetype
	private ddechannel, lasterr, topicstr, success, sagot,;
		openfdde, app2run

	if (filetype = 'DOC' or filetype = 'TXT')
		wait window 'Acquiring link. Please wait...' nowait

		= ddesetoption("Safety",.f.) [COLOR=green]&& turn off word's system messages[/color]
		= ddesetoption("Timeout",0)

		ddechannel = ddeinitiate("WinWord","System")
		lasterr = ddelasterror()
		app2run = 'C:\program files\microsoft office\office\winword.exe' [COLOR=green]&& haven't figured out how to automate this yet[/color]
		run /n7 &app2run

		ddechannel = ddeinitiate("WinWord","System")
		topicstr = dderequest(ddechannel,"Topics")

		if (lasterr > 0 or ddechannel = -1)
			openfdde = '[FileOpen "'+alltrim(upper(anyfile))+'"]'
			= ddeexecute(ddechannel,openfdde)

			_cliptext=''
			= ddeexecute(ddechannel,'[EditSelectAll]')
			= ddeexecute(ddechannel,'[EditCopy]')

			m.content = _cliptext [COLOR=green]&& store clipboard's content into a memomry variable[/color]
			_cliptext='' [COLOR=green]&& empty clipboard's content[/color]

			= ddeexecute(ddechannel,'[FileClose]')
			= ddeexecute(ddechannel,'[FileExit]')
			= ddeterminate(ddechannel)
			messagebox("File successfully copied.",0+64,"Success!")
		else
			= ddeexecute(ddechannel,'[FileExit]')
			= ddeterminate(ddechannel)
			messagebox("Link to file cancelled.",0+64,"Cancelled.")
		endif
	else
		_cliptext = "No applicable host program is available."
		messagebox(_cliptext,0+64,"System")
		m.content = _cliptext
		replace content with _cliptext
		_cliptext=''
	endif
endproc
the code above will copy the contents of a simple word doc or a txt file into a memory variable.

hope this helps. peace! [peace]

kilroy [trooper]
philippines

"If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get one million miles to the gallon, and explode once a year, killing everyone inside."
 
oooppss! apologies for not having read the entire thread. yes, you need to facilitate it with GetFile() and may have the need to use Append General to the general field.

hope this helps. peace! [peace]

kilroy [trooper]
philippines

"If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get one million miles to the gallon, and explode once a year, killing everyone inside."
 
We are linking to .PDF, .HTM, and .XLS
Perhaps the following code will give you an idea as to how I do it.

We scan in radiology equipment service reports using Acrobat and save the .pdf file in a directory. I have a table called Forms that connects a device/workorder number to that file name
Idno Wo Sn Filename
57578 187465 00055374 i:\BioMed\WOFiles\57578-187465.PDF

There is a button on the work order screen on top of the Work Order table (BioHist) we are looking at with this code in it:

* If there is a vendor WO view it
lcDefault = SET('DEFAULT')
lcDPath = SET('PATH')
lcFile = forms.FileName
lcExt = UPPER(JUSTEXT(lcFile))

DO CASE
CASE lcExt = "PDF"
lcPath = gcAdobePath
if empty(lcPath)
if getenv('USER') == 'ATS'
SET DEFAULT TO c:\progra~1\adobe\acroba~2.0\reader
SET PATH TO c:\progra~1\adobe\acroba~2.0\reader
else
if file("c:\progra~1\adobe\acroba~1.0\reader\AcroRd32.exe")
SET DEFAULT TO c:\progra~1\adobe\acroba~1.0\reader
SET PATH TO c:\progra~1\adobe\acroba~1.0\reader
else
if file("c:\progra~1\adobe\acroba~2.0\reader\AcroRd32.exe")
SET DEFAULT TO c:\progra~1\adobe\acroba~2.0\reader
SET PATH TO c:\progra~1\adobe\acroba~2.0\reader
endif
endif
endif

lcPath = LOCFILE("AcroRd32.exe", "exe","Locate Acrobat Reader")
if empty(lcPath)
ret = msgbox("Cannot find Acrobat Reader, please check","Warning",48)
else
lcFile = lcPath + " " + forms.FileName
wait "Please wait, loading Acrobat Reader..." window nowait
RUN /N &lcFile
wait clear
endif
else
lcFile = lcPath + " " + forms.FileName
wait "Please wait, loading Acrobat Reader..." window nowait
RUN /N &lcFile
wait clear
endif

CASE lcExt = "HTM"
lcPath = gcIEPath
if empty(lcPath)
SET DEFAULT TO c:\progra~1\intern~1
SET PATH TO c:\progra~1\intern~1
lcPath = LOCFILE("IEXPLORE.EXE", "exe","Locate Internet Explorer")
if empty(lcPath)
ret = msgbox("Cannot find Internet Explorer, please check","Warning",48)
else
lcFile = lcPath + " " + forms.FileName
wait "Please wait, loading Internext Explorer..." window nowait
RUN /N &lcFile
wait clear
endif
else
lcFile = lcPath + " " + forms.FileName
wait "Please wait, loading Internext Explorer..." window nowait
RUN /N &lcFile
wait clear
endif

CASE lcExt = "XLS"
IF FILE("C:\Program Files\Microsoft Office\Office10\EXCEL.EXE")
RUN /N "C:\Program Files\Microsoft Office\Office10\EXCEL.EXE " &lcFile
ELSE
ret = msgbox("Cannot find Excel, please check","Warning",48)
ENDIF
ENDCASE

set default to (lcDefault)
set path to (lcDPath)

select biohist


Tony Scarpelli
Clinical Engineering Dept.
Maine Medical Center
Portland, Maine 04102
 
Thanks for all the help and code. I will have a go based on the information supplied and let you know how I get on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top