Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2004
    Posts
    14

    Unanswered: Linking to an arbitrary document, browsing for and storing it

    Hi,

    I would like a table to have a field linked to a document outside of the database. I would like the form associated with the table tohave a button that can browse and pick the file to store/link, and another button to actually open the document with whatever program is associated with it. Can anyone help me to do this?

    thanks.

  2. #2
    Join Date
    Jun 2002
    Location
    Saudi Arabia / Philippines
    Posts
    126
    This is an automation and API question and a half. Luckily the API part is encapsulated in, I think, the scripting object or DLL. I know I've done it before but can't remember the details.

    I believe what your asking is some way of browsing the Windows directories to locate a document. This is where the scripting comes in. Then according to the file name extension determine which application to automate. This is a registry lookup. Then open that application (automation) and get it to display the document. I don't know of any way to fire up the application directly from the file name in a similar manner to double-clicking on it when you are in Explorer. I imagine there may be an API for this but whoa! Again can one use hyperlinks?

    I suppose the question is how familiar are you with all of the above techniques? Is there another way of doing this?
    Rod

    fe_rod@hotmail.com

  3. #3
    Join Date
    Jun 2004
    Posts
    14
    thanks for the reply. Each field that holds a link to a file will only hold a single type of file, so that can be hardcoded in, unless the link will open the file auto... that would be cool.

    So how do I open a browse window to pick the file and same the link?

    thanks.

  4. #4
    Join Date
    Jun 2004
    Posts
    14
    Please help?

  5. #5
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    Quote Originally Posted by galneweinhaw
    ...
    So how do I open a browse window to pick the file and same the link?

    thanks.
    I believe you need to use Common Dialog Control to pick a file. I don't know how to do it though. control should be somewhere in extra ActiveX control list.

    to execute a document create a module and copy following code that I found into it:
    Code:
    Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal Hwnd As Long, ByVal _
    				lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _
    				ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
     
    Declare Function GetForegroundWindow Lib "user32" () As Long
     
    Sub ShellEx(FileName As String)
    	ShellExecute GetForegroundWindow, "Open", FileName, "", "", 1
    End Sub
    then you can open any file with Shellex(filenamehere). example:
    ShellEx("c:\test.txt")
    ghozy.

  6. #6
    Join Date
    Jun 2002
    Location
    Saudi Arabia / Philippines
    Posts
    126
    One snag: the Common Dialog Control, cmdlg32.ocx if memory serves, is a VB control and is not supplied with VBA (Office). If you haven't bought VB then you will have to beg, borrow or steal it and I'm not sure where that leaves you legally vis-a-vis Microsoft.

    Other options are to have a look at the DIR function and see whether you can use that - tedious though it will prove to be - or investigate the Scripting Runtime library for useful functions.
    Last edited by Rod; 10-18-04 at 03:11.
    Rod

    fe_rod@hotmail.com

  7. #7
    Join Date
    Jun 2002
    Location
    Saudi Arabia / Philippines
    Posts
    126
    Hmm! I thought it would be a good idea if I also had this control. Now there seems to be confusion whether it's called cmdlg32.ocx or comdlg32.ocx. I found a copy of the latter, downloaded it and installed it.

    When I tried to use it however I got the 'You don't have a licence ... ' message. It seems Microsoft has the copyright angle covered.
    Rod

    fe_rod@hotmail.com

  8. #8
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    wrong reply please ignore.
    ghozy.

  9. #9
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    Rod, to be honest I never tried it before. it is in my list of activex controls even I don't have Visual Basic. But you are right, it asks for licence if you try to use it. but here is a link tells how to do it without common dialog control.
    http://www.developerfusion.com/show/2127/
    ghozy.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •