how to view large preview of an attachment?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elenaA
    New Member
    • Aug 2016
    • 42

    how to view large preview of an attachment?

    hello

    i want to ask something.

    i have a form in which i can put attachments like word, excel, pdf document,

    and now i want to have like a print preview screen of my attachemnts.

    let it say that i see that i have inside 3 documents i want to click with the mouse and choose the excel file and see it in large. before i will open it.

    somebody maybe know how to make like a display of what is in the attachment but in large view? something like that when you want to add image...only this time i want to see the documents s that are in the attachemnts in large view before i will open it and see the information.
  • mackenna
    New Member
    • Aug 2016
    • 3

    #2
    I think to make the preview more than the inherent program is simply impossible.

    Comment

    • PhilOfWalton
      Recognized Expert Top Contributor
      • Mar 2016
      • 1430

      #3
      If this is the sort of thing you are after, I'll have to refesh my memory how it was done.

      I know is shows Word docs, Excel, Pictures & internal reports PDFs.
      Can't remember what else.

      If this is the sort of thing your after, I'll have to refresh my mind how it's done.

      Phil

      Comment

      • jforbes
        Recognized Expert Top Contributor
        • Aug 2014
        • 1107

        #4
        How are you Attaching the documents? Are using Access' Attachment Data Type? Or are you using a Text Data Type and storing the Path and FileName to the Attachment?

        It you are using Access' Attachments, then I don't know of a good way.

        If you are storing the Path to the Database (which I highly recommend), then you can use a WebBrowser Control (or and Image Control for Image Mime Types) and Navigate to the file and the WebBrowser will display it.

        Comment

        • PhilOfWalton
          Recognized Expert Top Contributor
          • Mar 2016
          • 1430

          #5
          I will go into more details if necessary, but briefly there is an unbound object frame called Letter and an image called ImageOverlay.
          Both are the same size and cover one another.

          Depending on what you are viewing, one or other of these is hidden.

          Below is some of the code. The missing bits are all over the database (and a referenced database) so difficult to find. It's probably reasonably obvious what they do.

          Code:
          Private Sub Form_Current()
          
              Dim MyDb As Database
              Dim SuffixSet As Recordset
              Dim Suffix As String
              Dim Criteria As String
          
              On Error GoTo Form_Curr_Err
          
              If Nz(DocID) = 0 Then               ' New Document
                  Letter.SourceDoc = ""
                  Letter.Visible = False
                  ImageOverlay.Picture = "(none)"
                  Exit Sub
              End If
              
              If CheckFileExists(DocID) = False Or IsNull(DocName) Then
                  Letter.Visible = False
                  ImageOverlay.Visible = True
                  ImageOverlay.Picture = Dlookup("IconPath", "QCoInfoPaths") & "\File not found.png"
                  Exit Sub
              End If
              
              Set MyDb = CurrentDb
              Set SuffixSet = MyDb.OpenRecordset("SELECT DocSuffixes.* FROM DocSuffixes")
          
              Suffix = Right(DocName, Len(DocName) - InStrRev(DocName, "."))
              Criteria = "DocSuffix = " & Chr$(34) & Suffix & Chr$(34)
              
              With SuffixSet
                  .FindFirst Criteria
                  If .NoMatch Then
                      MsgBox "Document type " & Suffix & " not recognised", vbInformation
                      Letter.Visible = False
                      ImageOverlay.Picture = "(none)"
                      GoTo CloseIt
                  End If
                  If !DocSuffixTypeID = 1 Then                        ' Picture (BMP, JPG, JPEG, GIF, DIB, PNG, TIF, ICO & any others)
                      ImageOverlay.Visible = True
                      Letter.Visible = False
                      With ImageOverlay
                          .Picture = Path & DocName
                      End With
                      DocTypeID = 4                                   ' Fixed
                  ElseIf !DocSuffixTypeID = 2 Then                    ' Word, Excel, (PDF DOC, DOCX, PDF, XLS, XLSX, CSV, RTF any others)
                      ImageOverlay.Visible = False
                      Letter.Visible = True
                      With Letter
                          .SourceDoc = Path & DocName
                          .Action = acOLECreateLink
                          .OLETypeAllowed = acOLELinked
                          .Enabled = True
                          .Locked = False
                      End With
                      If Nz(DocTypeID) < 3 Then                       ' Must be fixed or mail merge
                          MsgBox "You must select the Type of Document", vbInformation
                          DocTypeID.SetFocus
                      End If
                  End If
          CloseIt:
                  .Close
                  Set SuffixSet = Nothing
              End With
          
          Form_Current_Exit:
              Exit Sub
              
          Form_Curr_Err:
              If Err = 2786 Then
                  MsgBox "You can only link to Bitmap (.Bmp) pictures", vbCritical
              ElseIf Err = 3021 Then                  ' No current record so no file loaded
                  Resume Form_Current_Exit
              Else
                  MsgBox Err.Description
              End If
              
          End Sub
          This is the table DocTypes
          Code:
          DocTypeID	DocType
          1	Internal fixed report (E.g. letters)
          2	Internal Variable (E.g. Invoice)
          3	External Mail Merge
          4	External Docs (E.g. letters, Excel, PDF)
          This the DocSuffixes Table
          Code:
          DocSuffix	DocSuffixTypeID
          AccDb	2
          BMP	1
          CSV	2
          DIB	1
          Doc	2
          DocX	2
          GIF	1
          ICO	1
          JPG	1
          PDF	2
          PNG	1
          RTF	2
          TIF	1
          XLS	2
          XLSX	2
          and finally
          Dlookup("IconPa th", "QCoInfoPat hs") & "\File not found.png"
          just finds a picture that says "File Not Found"

          Hope this helps. The picture sent in my last reply should help

          Phil

          Comment

          • elenaA
            New Member
            • Aug 2016
            • 42

            #6
            hello everybody

            first thanks to all replies.

            well in my database- I am using microsft access I make a field which will store documents.this is access atachments yes. so far I understand that this option is not ok? is the problem becouse of storage the database? that I will use very mb in storage? you suggest me web broswer? how is that working?

            let say that I have 3 documents in my computer and I want that everxbody can see it? you mean that with web broser that is posible? that somebody will just click and he will see it?


            Mister Phil, the code you give me. where I have to put that? I have to make some command button and then paste the code?

            is that ok working? I read that I also need some tables? is that correct?

            you know I want to make my perfect database. every day I have a lot of ideas what I want to have. for now I am on my 80%. I want to make some thing more and then maybe I will manage the perfection.

            i am working in company that have a lot of results. exl, pdf, word.... my idea is that now and forever we have all together. i am also thinking to make path to the files maybe becouse of the amount of the files...but I wanted to have realy all together in one place ..just to click and to see the results. this with attachments in very good but i read on the internet that access can store only 2GB of data ? is that true? is posible to make access to store more? and how? with sql server?

            Comment

            • PhilOfWalton
              Recognized Expert Top Contributor
              • Mar 2016
              • 1430

              #7
              As you see from the code, it is on the OnCurrent of the form, so as you change records, you see a different Word Doc, Excel file, picture, PDF etc.

              Phil

              Comment

              • elenaA
                New Member
                • Aug 2016
                • 42

                #8
                can you write which fields of the tables you put on your form?

                thank you

                Comment

                • PhilOfWalton
                  Recognized Expert Top Contributor
                  • Mar 2016
                  • 1430

                  #9
                  This is the table Docs
                  Code:
                      DocID     Auto    PK
                      DocName   Text
                      DocDesc   Text
                      Path      Text (Path of Document (Excluding DocName)
                      DocTypeID Long    FK
                  Phil

                  Comment

                  • elenaA
                    New Member
                    • Aug 2016
                    • 42

                    #10
                    hello

                    what mean the last line?

                    DocTypeID Long FK

                    what is FK?? PK is primary key no? and PK?

                    what type is long?

                    thank you

                    Comment

                    • elenaA
                      New Member
                      • Aug 2016
                      • 42

                      #11
                      aha FK is foreign key...

                      aha ok

                      i will try to make it...for now i have still problems in the code...with source SourceDoc

                      Comment

                      • elenaA
                        New Member
                        • Aug 2016
                        • 42

                        #12
                        hello Phil

                        i am looking the code now for 2 days and something is missing in the code. i still dont get nothing...

                        maybe you know what is missing?

                        Comment

                        • jforbes
                          Recognized Expert Top Contributor
                          • Aug 2014
                          • 1107

                          #13
                          elenaA

                          Please take the time to research the problem before you post your question. The experts here are more than willing to help you with a specific problem but you have to do your part to learn the basics and also formulate a specific question we can help with. Please take the time to read over the Posting Guidelines, specifically the section on Before you Post your Question.

                          Before posting any question you are expected to attempt to find and work on a solution. When you find a specific problem with your attempt, that is the time to post here requesting assistance with any difficulties you have or about a particular function of the code that you don't know how to achieve. When posting your problem, details of the problem itself and where it's found are the bare minimum information required. The experts on this site are more than happy to help you with your problems but they cannot do your programing for you.

                          Code may be posted for reference purposes, but please don't expect us to work out the meaning of your problem by reverse-engineering your code. The question you post must make sense in its own right.
                          Last edited by jforbes; Aug 10 '16, 05:35 PM. Reason: Thanks for the template, NeoPa

                          Comment

                          • elenaA
                            New Member
                            • Aug 2016
                            • 42

                            #14
                            i understand

                            sorry to all..i will never more disturb

                            thank you for all mister Phil

                            bye

                            Comment

                            • PhilOfWalton
                              Recognized Expert Top Contributor
                              • Mar 2016
                              • 1430

                              #15
                              It's going to take so long to sort you out, here is a database.

                              There will be errors. As JForbes has said, you will need to do some work yourself.#

                              Phil

                              Comment

                              Working...