dBASE Programming - Ole Fieldtype

This is Interesting: Free IT Magazines  
Home > Archive > dBASE Programming > March 2007 > Ole Fieldtype





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Ole Fieldtype
Dennis Spiess

2007-03-05, 7:17 pm

Hi,
dBase Plus 2.6
I am trying to use an ole field to link to various external files, they may be an html, dbf or Word file. From a form I would like to allow a user to either add a file to the ole field, change the file or remove the link.
I have searched all over to try and find out how to do this. So far i find i can only do it from a grid which is not proactacal for the application. A 'set' of buttons would be fine or something else.
This seems to be one of those subjects with very littel documentation.
Thanks for reading this and your help,
Den
Dan Goldberg

2007-03-06, 1:18 am

Hi Dennis
I'm not sure if this will help but I use the following code to import
the path of various files to a field "fieldpath". And then I use that
field to launch the application with the file.

local cFile
local MDATE
cFile = getfile("*.*", "Import Image")
if "" # cFile
form.fieldpath.value = cfile
endif
return

From a browse I have this event to launch the application using the
path from the "fieldpath"

function DGGRID1_onLeftDblClick(flags, col, row)
MMODEL = form.rowset.fields["sfilepatch"].value
#include <Winuser.h>
extern HINSTANCE ShellExecute(HANDLE, LPCSTR, LPCSTR, LPCSTR, ;
LPCSTR, CINT) shell32 ;
from "ShellExecuteA"
ShellExecute( _app.FrameWin.hwnd, "open", MMODEL, Null,
"C:\Windows", SW_SHOWNORMAL )
return

Dan













> Hi,
> dBase Plus 2.6
> I am trying to use an ole field to link to various external files, they may be an html, dbf or Word file. From a form I would like to allow a user to either add a file to the ole field, change the file or remove the link.
> I have searched all over to try and find out how to do this. So far i find i can only do it from a grid which is not proactacal for the application. A 'set' of buttons would be fine or something else.
> This seems to be one of those subjects with very littel documentation.
> Thanks for reading this and your help,
> Den

Geoff Wass [dBVIPS]

2007-03-06, 1:18 am

In article <gfHLsU2XHHA.1060@news-server>,
dennis.spiess@reckittbenckiser.com says...
> Hi,
> dBase Plus 2.6
> I am trying to use an ole field to link to various external files, they may be an html, dbf or Word file. From a form I would like to allow a user to either add a file to the ole field, change the file or remove the link.
> I have searched all over to try and find out how to do this. So far i find i can only do it from a grid which is not proactacal for the application. A 'set' of buttons would be fine or something else.
> This seems to be one of those subjects with very littel documentation.
> Thanks for reading this and your help,
> Den
>

Dennis,

If you are trying to use the OLE field and LINK to a file, you need to
use the old XDML commands as the newer ODML can only embed the file. See
the documentation for REPLACE OLE in the on-line help.

So, you will need to use the old-style commands:

// yourKey is an index in yourTable
USE yourTable ORDER yourKey

// yourKeyValue is a specific yourKey value so you can
// find the row you want.
if SEEK( yourKeyValue )
REPLACE OLE yourOLEfieldname FROM yourFileName.doc LINK
else
msgbox( "Sorry, the row was not found" )
endif

USE // close table


In order to make things variables, I think you can do something like
this:

// cYourTable is a variable containing the name of the table
// yourKey is an index in yourTable
USE ( cYourTable ) ORDER yourKey

// yourKeyValue is a specific yourKey value so you can
// find the row you want.
// cYourFileName is a variable holding the name of the file
if SEEK( yourKeyValue )
REPLACE OLE yourOLEfieldname FROM ( cYourFileName ) LINK
else
msgbox( "Sorry, the row was not found" )
endif

USE // close table

--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

..|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
..|.|.| ---------------------------------------------------------- |.|.|.
..|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Den

2007-03-06, 7:21 am

Geoff,
Thanks for the reply. I have been able to get the linked file into the OLE field using something similar to your code. I have not been successful at getting the file displayed. Clicking on the OLE field in a grid works but i would like to open the file fr
om a push button. The program is displaying the record that contains the OLE field. There is no grid displayed on the page. How do I get the file to open??
Den
-------------------------------------------------------------------
Geoff Wass [dBVIPS] Wrote:

> In article <gfHLsU2XHHA.1060@news-server>,
> dennis.spiess@reckittbenckiser.com says...
> Dennis,
>
> If you are trying to use the OLE field and LINK to a file, you need to
> use the old XDML commands as the newer ODML can only embed the file. See
> the documentation for REPLACE OLE in the on-line help.
>
> So, you will need to use the old-style commands:
>
> // yourKey is an index in yourTable
> USE yourTable ORDER yourKey
>
> // yourKeyValue is a specific yourKey value so you can
> // find the row you want.
> if SEEK( yourKeyValue )
> REPLACE OLE yourOLEfieldname FROM yourFileName.doc LINK
> else
> msgbox( \"Sorry, the row was not found\" )
> endif
>
> USE // close table
>
>
> In order to make things variables, I think you can do something like
> this:
>
> // cYourTable is a variable containing the name of the table
> // yourKey is an index in yourTable
> USE ( cYourTable ) ORDER yourKey
>
> // yourKeyValue is a specific yourKey value so you can
> // find the row you want.
> // cYourFileName is a variable holding the name of the file
> if SEEK( yourKeyValue )
> REPLACE OLE yourOLEfieldname FROM ( cYourFileName ) LINK
> else
> msgbox( \"Sorry, the row was not found\" )
> endif
>
> USE // close table
>
> --
> Geoff Wass [dBVIPS]
> Montréal, Québec, Canada
>
> .|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
> .|.|.| ---------------------------------------------------------- |.|.|.
> .|.|.| IT Consultant http://Geoff_Wass.com |.|.|.


Den

2007-03-06, 1:19 pm

Dan,
This is real neat... works very well and does not use the OLE field... I like it. Curiosity still points to getting the OLE filed working but will pursue tis code too as it can easily fit in my app.
Thanks
D
-----------------------------------
Dan Goldberg Wrote:
[vbcol=seagreen]
> Hi Dennis
> I'm not sure if this will help but I use the following code to import
> the path of various files to a field "fieldpath". And then I use that
> field to launch the application with the file.
>
> local cFile
> local MDATE
> cFile = getfile("*.*", "Import Image")
> if "" # cFile
> form.fieldpath.value = cfile
> endif
> return
>
> From a browse I have this event to launch the application using the
> path from the "fieldpath"
>
> function DGGRID1_onLeftDblClick(flags, col, row)
> MMODEL = form.rowset.fields["sfilepatch"].value
> #include <Winuser.h>
> extern HINSTANCE ShellExecute(HANDLE, LPCSTR, LPCSTR, LPCSTR, ;
> LPCSTR, CINT) shell32 ;
> from "ShellExecuteA"
> ShellExecute( _app.FrameWin.hwnd, "open", MMODEL, Null,
> "C:\Windows", SW_SHOWNORMAL )
> return
>
> Dan
>
>
>
>
>
>
>
>
>
>
>
>
>

Den

2007-03-06, 1:19 pm

Oops:
Where can I get more documentation on what you did here?
I would like to understand the code ....
Den
Ken Mayer [dBVIPS]

2007-03-06, 1:19 pm

Den wrote:
> Dan,
> This is real neat... works very well and does not use the OLE field... I like it. Curiosity still points to getting the OLE filed working but will pursue tis code too as it can easily fit in my app.


Frankly, OLE was never that well implemented by Microsoft, and is a bit
of a PITA to work with. I'd go with the simpler, non-OLE method first.

Ken

--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/dbase/dBASEBook.htm
http://www.goldenstag.net/dbase/dBASEReportsBook.htm
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
Geoff Wass [dBVIPS]

2007-03-07, 1:25 am

In article <oGBTm$#XHHA.1796@news-server>,
dennis.spiess@reckittbenckiser.com says...
> Geoff,
> Thanks for the reply. I have been able to get the linked file into the OLE field using something similar to your code. I have not been successful at getting the file displayed. Clicking on the OLE field in a grid works but i

would like to open the file from a push button. The program is displaying the record that contains the OLE field. There is no grid displayed on the page. How do I get the file to open??
> Den



Den,

Can you post your code? You should have an OLE object on the form and it
should be dataLinked to the field in your table. It should work.

--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

..|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
..|.|.| ---------------------------------------------------------- |.|.|.
..|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com