#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2008
    Posts
    23
    Rep Power
    0

    Question Link to a file (ie: pdf, doc, etc)


    Hi everyone.
    I am considering adding a new feature to our customer database. Let's say we recieve a letter from a customer, I'd like to be able to scan the letter into the computer, saved as a PDF (for example) and then, on the customer form, provide a 'browse' button so that we could browse to the file and then the address of the file gets saved as a text field in the relevant table.

    Next time someone brings up the details for that customer, the letter would be accessible via a hyperlink to the file.

    It sounds relatively straight-forward, but is it?

    Thanks

    Martin
  2. #2
  3. Registered Hero
    ASP Adventurer (500 - 999 posts)

    Join Date
    Oct 2006
    Posts
    976
    Rep Power
    1330
    Originally Posted by SpireWindows
    Hi everyone.
    I am considering adding a new feature to our customer database. Let's say we recieve a letter from a customer, I'd like to be able to scan the letter into the computer, saved as a PDF (for example) and then, on the customer form, provide a 'browse' button so that we could browse to the file and then the address of the file gets saved as a text field in the relevant table.

    Next time someone brings up the details for that customer, the letter would be accessible via a hyperlink to the file.

    It sounds relatively straight-forward, but is it?

    Thanks

    Martin
    Is it always going to be PDF? if not, just create a hyper link field which will contain the document address.

    If it is always going to be a PDF you can use the following in a command button. This works by by saving the PDF as the same name as a letterid field on your form. And you will always save any letters in the same folder, (which is good practice anyway).

    Obvioulsy stAppName must equal the exact adress of Adobe Acrobat.

    If you do want to use this method i sugest you make a sub form, tabular. With fields, Cutomer ID, Letter ID, Description. and put a command button on the side.

    Code:
    Private Sub Command_Click()
    
    On Error GoTo Err_Command_Click 
    
        Dim stAppName As String
    
        Dim varFile As String
        
    
        varFile = "S:\FolderNAme\" & [LetterIDField] & ".pdf"
    
        stAppName = "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe " & varFile
    
        Call Shell(stAppName, 1)    
    
    Exit_Command_Click:
    
        Exit Sub 
    
    Err_Command_Click:
    
        MsgBox Err.Description
    
        Resume Exit_Command_Click
    
    End Sub
    Last edited by AOG123; February 12th, 2008 at 03:47 AM.
  4. #3
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2008
    Posts
    23
    Rep Power
    0
    Originally Posted by AOG123
    varFile = "S:\FolderNAme\" & [LetterIDField] & ".pdf"

    stAppName = "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe " & varFile
    End Sub[/CODE]
    Thanks for that. It all makes sense. However, I'm in charge of developing features for 'dummies' - and to do that I have to make sure that what I implement is simple. Chances are that the person who scans in the letter will save it as something like

    Mr Smith - Feb07 - Letter.pdf

    Is it possible to have a 'browse' button on the form so that the file can be browsed to and then the filename stored in a field 'FullFileName'?

    Then varFile = "S:\FolderNAme\" & [LetterIDField] & ".pdf"
    would become
    varFile = "S:\FolderNAme\" & [FullFileName]

    I'm pretty sure they would always be PDFs.

    Martin
  6. #4
  7. Registered Hero
    ASP Adventurer (500 - 999 posts)

    Join Date
    Oct 2006
    Posts
    976
    Rep Power
    1330
    Originally Posted by SpireWindows
    Thanks for that. It all makes sense. However, I'm in charge of developing features for 'dummies' - and to do that I have to make sure that what I implement is simple. Chances are that the person who scans in the letter will save it as something like

    Mr Smith - Feb07 - Letter.pdf

    Is it possible to have a 'browse' button on the form so that the file can be browsed to and then the filename stored in a field 'FullFileName'?

    Then varFile = "S:\FolderNAme\" & [LetterIDField] & ".pdf"
    would become
    varFile = "S:\FolderNAme\" & [FullFileName]

    I'm pretty sure they would always be PDFs.

    Martin
    They will all have to be PDF, otherwise you'll have to do this with true hyperlinks.

    I've created a sample (credit to www.lebans.com) for the OPENFILENAME modules.

    This was an absolute pain to put together, so i hope you appreciate it

    I'm not gonna explain how this is working, cause it will be a 10 page essay.

    All you need to do is make sure the Adobe File path is correct.
    (please note this method does not support hyperlinks)

    Your gonna need to take a real good look into how this is working if you want to impliment it into your db.

    I'm in charge of developing features for 'dummies'
    Maybe i should get a job as developer.

    Thanks AOG

    Comments on this post

    • SpireWindows agrees : Thank you.
    Attached Files
    Last edited by AOG123; February 12th, 2008 at 06:27 AM.
  8. #5
  9. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2008
    Posts
    23
    Rep Power
    0
    That is fantastic. Thank you.

    And if I install Acrobat Reader in the same location on every users PC it would be 100%, but some computers have Acrobat and some have Reader. So there is a variation to the code for each user's PC.

    However, I had a thought - What if I install a basic PDF reader on everone's PC in a fixed location (for example they all have the front-end of the database in c:\Database and I could put something like Sumatra in there) so that there's no messing about with code depending on what PDF app each user has.

    I just need to find a basic PDF reader that I can use with the lines

    varFile = [InputfileName] & ""
    stAppName = "C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe " & varFile

    Call Shell(stAppName, 1)

    I tried replacing Acrobat with the path to Sumatra and it won't open a PDF from a command line in teh same way that Acrobat does.

    But, I think, if I can find a PDF readert that is small so I can drop it in to the same folder on all PCs, it will be a perfect solution.

    Thanks for your help.

    Martin
  10. #6
  11. Registered Hero
    ASP Adventurer (500 - 999 posts)

    Join Date
    Oct 2006
    Posts
    976
    Rep Power
    1330
    Originally Posted by SpireWindows
    That is fantastic. Thank you.

    And if I install Acrobat Reader in the same location on every users PC it would be 100%, but some computers have Acrobat and some have Reader. So there is a variation to the code for each user's PC.

    However, I had a thought - What if I install a basic PDF reader on everone's PC in a fixed location (for example they all have the front-end of the database in c:\Database and I could put something like Sumatra in there) so that there's no messing about with code depending on what PDF app each user has.

    I just need to find a basic PDF reader that I can use with the lines

    varFile = [InputfileName] & ""
    stAppName = "C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe " & varFile

    Call Shell(stAppName, 1)

    I tried replacing Acrobat with the path to Sumatra and it won't open a PDF from a command line in teh same way that Acrobat does.

    But, I think, if I can find a PDF readert that is small so I can drop it in to the same folder on all PCs, it will be a perfect solution.

    Thanks for your help.

    Martin
    Glad it helped, it looks like your on top of things with this,.

    If you need any help with pdf viewer, let me know.. (if i'm not around, someone else will have some good advice).
  12. #7
  13. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2008
    Posts
    23
    Rep Power
    0
    I tried a couple of viewers (Sumatra and FoxitReader) and neither will accept a command to open the PDF file from within Access. So I downloaded the latest Adobe Reader (8) and installed it.

    When I first tested the sample database and used Acrobat to open the PDFs it worked absolutely perfect, but with Reader version 8 it does not.

    stAppName = "C:\Program Files\Adobe\Reader\Reader\AcroRd32.exe " & varFile

    Produces an error in Adobe Reader: "There was an error opening this document. This file cannot be found."

    Now I'm stumped!!!

    Big shout out for some help.

    Martin
  14. #8
  15. Registered Hero
    ASP Adventurer (500 - 999 posts)

    Join Date
    Oct 2006
    Posts
    976
    Rep Power
    1330
    Originally Posted by SpireWindows
    I tried a couple of viewers (Sumatra and FoxitReader) and neither will accept a command to open the PDF file from within Access. So I downloaded the latest Adobe Reader (8) and installed it.

    When I first tested the sample database and used Acrobat to open the PDFs it worked absolutely perfect, but with Reader version 8 it does not.

    stAppName = "C:\Program Files\Adobe\Reader\Reader\AcroRd32.exe " & varFile

    Produces an error in Adobe Reader: "There was an error opening this document. This file cannot be found."

    Now I'm stumped!!!

    Big shout out for some help.

    Martin
    For Adobe 8

    The file path should look like

    stAppName = "C:\Program Files\Adobe\Acrobat 8.0\Reader\AcroRd32.exe " & varFile

    I think. (based on my version 7.0 specifying the version type in the path).
  16. #9
  17. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2008
    Posts
    23
    Rep Power
    0
    I checked - and it is ...Reader\Reader... because I dropped the 8.0 from the path so that whatever Reader installs (9, 10, 11 etc.,) would not mean having to change the code in the database. Also, I chose C:\Program Files\Adobe\Reader as the path and the install created another folder called 'Reader' inside the path I selected...

    Cos installs are so smart...

    So the path is correct at my end.

    Martin
  18. #10
  19. Registered Hero
    ASP Adventurer (500 - 999 posts)

    Join Date
    Oct 2006
    Posts
    976
    Rep Power
    1330
    Originally Posted by SpireWindows
    I checked - and it is ...Reader\Reader... because I dropped the 8.0 from the path so that whatever Reader installs (9, 10, 11 etc.,) would not mean having to change the code in the database. Also, I chose C:\Program Files\Adobe\Reader as the path and the install created another folder called 'Reader' inside the path I selected...

    Cos installs are so smart...

    So the path is correct at my end.

    Martin
    Ok, i'm pretty busy at the moment, so won't be able to try to replicate whats happening.. I'll have a word with one of the regulars to see if they can have a look. Or maybe someone else here can.

    If you have no responce, i'll have a look i get some time.
  20. #11
  21. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2008
    Posts
    23
    Rep Power
    0
    Thanks for your help today - I've certainly picked up some useful advise.
  22. #12
  23. No Profile Picture
    Moderator
    ASP Mastermind (5000+ posts)

    Join Date
    Feb 2004
    Location
    Reston, VA
    Posts
    13,248
    Rep Power
    1907
    The only thing I can suggest for you is to use the File System Object to search "C:\Program Files" for "AcroRd32.exe". You can then return the path, store it in a variable and then use that variable to open that application. You can also use this to check if the application exists on the computer. If it doesn't, then the user obviously won't be able to open the document, anyway.

    Here's a tutorial about the File System Object for VBA.
    jmurrayhead

Similar Threads

  1. Urgent Link Query (please!)
    By PhilCollins99 in forum Microsoft IIS
    Replies: 8
    Last Post: January 16th, 2007, 08:30 AM
  2. Link to local image file in ASP
    By mlam in forum ASP Development
    Replies: 6
    Last Post: September 9th, 2005, 05:31 AM
  3. MHTMLRedir.Exploit - Revisited
    By Tolik in forum Windows OS
    Replies: 8
    Last Post: August 9th, 2005, 05:18 AM
  4. Document link gap file name problem
    By chrismogz in forum ASP Development
    Replies: 3
    Last Post: August 8th, 2005, 04:37 AM
  5. How do I link to a file server with img tag
    By Bigced in forum ASP Development
    Replies: 8
    Last Post: June 23rd, 2004, 04:42 PM

IMN logo majestic logo threadwatch logo seochat tools logo