Results 1 to 5 of 5

Thread: Pull word Doc from Access database..

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2003
    Location
    Cincy
    Posts
    55

    Question Pull word Doc from Access database..

    I have a program that I am writing to save word docs to a database. I would like to save the docs in the database this seems easy enough, but how can I pull those documents out of the DB to allow the user to view using a command button, or whatever I decide.???

    I am able save the doc to the DB, but I am not sure after that.
    What I want to do is...... I have several docs that pertain to certian customer, or sales rep. I would like to be able to allow the user to search through the database based upon customer, or sales rep criteria and then select the doc they want to see from that filtered down criteria. I am not sure if I am going to use a datagrid to dispaly the criteria they filtered, then allow them to double click on the item they want then dispaly the doc.. At this point I am not sure how I am going to do it....... because I am not even sure how to pull the doc out of the DB.. Please point me in the right direction..... Thanks

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    Easiest way is to have a folder near to the mdb where you store the Doc files.

    Then store a path to the doc files and open these in word (automation) as read only... if you want.

    Storing the doc in a db doesn't seem to be a good idea, but if you need to go that way, either open word (automation) then paste the doc in, possibly via clipboard, or go through what is held and write it to the doc.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Okay so you've read my tutorial thingy on Saving Any File Type.
    It contains a few vital procedures that do all the work.

    Do you get how to add and retrieve files from a db?
    Do you have it working?

    If so for the searching part simply add some fields like filename, date modified, summary etc.
    They can search\view it by those fields.

    Does that make sense?
    b

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2003
    Location
    Cincy
    Posts
    55

    How to open or retrieve file..

    I am able to add the WORD Docs to the db.. Now how do I retrieve them?? I would like to be able to let the user select the word doc with a click event on a datagrid, or just use a command button to pull and open the word docs in MSWORD. so far I am able to pull the doc just using the file name, but this just kind of defeats the purpose of storing the docs in the db.. Please give me a clue.... Thanks...

  5. #5
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    By the filename i meant store that AS well, it just looks better.

    Now retrieving data out is in my thread about Storing Any File Type In A Database

    For Word Docs what i'd do is use the shell execute function

    VB Code:
    1. Option Explicit
    2. Private 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
    3. Private Const SW_MAXIMIZE = 3
    4.  
    5.  Private Sub cmdGet_Click()
    6.  
    7.             'check for temporary file if it's found delete it
    8.             temp = App.Path & "\" & txtfilename.Text 'txtfilename holds the files name
    9.             If Len(Dir(temp)) > 0 Then
    10.                 Kill temp
    11.             End If
    12.  
    13.             'Open temp file
    14.             file = FreeFile
    15.             Open temp For Binary As #file
    16.  
    17.             'Read temp file as binary into chunk
    18.             'this is the engine room
    19.             ImgeSze = rs("FILE").ActualSize
    20.             Do While offset < ImgeSze
    21.                chunk() = rs("FILE").GetChunk(ChunkSize)
    22.                Put #file, , chunk()
    23.                offset = offset + ChunkSize
    24.             Loop
    25.  
    26.             Close #file
    27.  
    28. ShellExecute Me.hwnd, vbNullString, temp ,vbNullString, vbNullString, SW_MAXIMIZE
    29.  
    30. 'this is to load it's path name into the text box
    31. End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width