Drag en Drop documenten beheer

Status
Niet open voor verdere reacties.

Peer44

Gebruiker
Lid geworden
25 jan 2008
Berichten
224
Hallo,

ik ben opzoek naar een manier om makkelijker externe documenten te koppelen aan access 2010.

Ik heb nu een een tabel met klachtenregistratie.
Daar heb ik een formulier van gemaakt waar via bijlages invoegen de documenten gekoppeld kunnen worden, aan het klachtenID.

Maar nu wil ik dat je bijvoorbeeld vanuit outlook een mail selecteert, sleept naar het access formulier, los laat en de koppeling automatisch gemaakt wordt.
de database wordt door meerdere personen gebruikt, er moet een centrale opslagfolder gebruikt gaan worden op het netwerk zodat iedereen de documenten ook kan openen.
Iemand enig idee hoe dit werkt?
 
Ik neem aan dat je i.v.m. de beheersbaarheid van de db de bijlagen niet als OLE object wilt opslaan, maar alleen een padverwijzing wilt toevoegen, die je dan kunt gebruiken om met een hyperlink de bestanden te openen. Bijlagen in de db opslaan zorgt er vermoedelijk voor dat je binnen een half jaar een nieuwe database kan gaan bouwen, omdat het bestand te groot is geworden. Dus dat zul je niet willen.

Om op de vraag terug te komen: dat zou nog wel kunnen, als je een procedure hebt die een bijlage eerst opslaat. Je kunt alleen fysieke bestanden opslaan in de db, en een bijlage in een mail is dat niet. Het bestand moet dus echt op een schijf staan.
Dus hoever ben je daar mee? Bij UtterAccess vind je twee voorbeelden waarmee je het importeren kunt automatiseren. Het is nogal wat code, dus die hier knippen en plakken heeft bar weinig zin :)
 
Octafish,

ik heb nog gezocht heb inmiddels iets wat aardig in de richting komt het werkt alleen nog niet 100%
de eerste keer dat je gaat slepen en neerzetten werkt!
de tweede keer niet meer, dan moet je eerst het bestand afsluiten en weer opnieuw openen voordat het weer wil werken........
Hopelijk kun jij zien waar het probleem zit.Bekijk bijlage Database1.rar

Code:
Option Compare Database
Option Explicit



Private Sub EmailMemo_Dirty(Cancel As Integer)

    'I got the guts of this sub from Remou on tek-tips.com. S/he told me I can drag and drop an
    'email to a memo field, then gave me the object control code to save the file.
    Dim olApp As Outlook.Application
    Dim olExp As Outlook.Explorer
    Dim olSel As Outlook.Selection
    Dim i, intCounter, intResponse As Integer
    Dim strFilename, strSQL, strFolderPath, strPathAndFile, strMsg As String
    Dim fs As Object
    Dim fsFolder As Object
    Dim blnFolderExists, blnFileExists As Boolean
    
    'This field is used to control attaching emails by dropping them on the field.
    'To allow this the field must be editable. This means the user could accidentally
    'type in the field and trigger the code to attach an email. Therefore, this user
    'verification makes sure the user intentionally dropped an email on the field.
    strMsg = "WARNING: You have triggered the E-mail Attachment Function. CHOOSE CAREFULLY ..." & vbCr & vbCr
    strMsg = strMsg & "If you intended to attach an e-mail to this note, answer Yes below. "
    strMsg = strMsg & "If you did not intend to attach an e-mail and don't know what's going on, "
    strMsg = strMsg & "answer No below." & vbCr & vbCr
    strMsg = strMsg & "Did you intentionally drag and drop an e-mail to attach it to this note?"
    intResponse = MsgBox(strMsg, vbYesNo)
    If intResponse = 7 Then 'No
        Cancel = True
        Exit Sub
    End If
    
    'My network consultant advises not putting too many files in a folder - like our Permanent Images.
    'Therefore, I will separate emails into a new folder each year. This code allows me
    'to never check on it, by creating the folder automatically when the year changes.
    Set fsFolder = CreateObject("Scripting.FileSystemObject")
    strFolderPath = "C:\test " & Year(Date)
    If fsFolder.FolderExists(strFolderPath) = False Then
        fsFolder.CreateFolder (strFolderPath)
    End If

    'Create the filename as a message file from the ClientID and the NoteID - which will be unique
    strFilename = Me.txtClientID & "_" & Me![SvcNoteID] & ".msg"
    
    'Combine for full path and file name
    strPathAndFile = strFolderPath & "\" & strFilename
    
    'Make sure this file does not already exist to avoid overwriting email files when there is a
    'system glitch.
    Set fs = CreateObject("Scripting.FileSystemObject")
    blnFileExists = fs.FileExists(strPathAndFile)
    If blnFileExists = False Then
        'There's not already a file for this client and noteID. This is the way it always
        'should be. But stuff happens. So, I'm checking.
        'Save the email to the filename just created as a message file
        Set olApp = GetObject(, "Outlook.Application")  'First argument is blank to return the currently
                                                        'active Outlook object, otherwise runtime fails
        Set olExp = olApp.ActiveExplorer
        Set olSel = olExp.Selection
        For i = 1 To olSel.Count
            olSel.Item(1).SaveAs strPathAndFile, olMSG
        Next
    Else
        'There's already a file for this client and noteID. This should be impossible,
        'but stuff happens. In this case we notify the user and then re-establish the links
        'so the user can handle it.
        strMsg = "ATTENTION: The system detected an e-mail file already created for this note. "
        strMsg = strMsg & "That e-mail is now linked to this note ID. Please do the following:" & vbCr & vbCr
        strMsg = strMsg & "1. View the e-mail normally." & vbCr
        strMsg = strMsg & "2. If it is the correct e-mail, you don't need to do anything else." & vbCr
        strMsg = strMsg & "3. If it is the wrong e-mail, use the Un-Attach E-mail button to get rid of it. "
        strMsg = strMsg & "Then attach the correct e-mail."
        MsgBox strMsg
    End If
    
    'Update the location field with the location.
    Cancel = True   'To roll back changes caused by the drop.
    Me![Emaillocation] = strPathAndFile
    Me.Emailmemo = "EMAIL ATTACHED: Click Here To View"
    Me.Emailmemo.Locked = True
    Me.Dirty = False    'To save the changes.
    
    Set fsFolder = Nothing
    Set fs = Nothing
    Set olSel = Nothing
    Set olExp = Nothing
    Set olApp = Nothing
    
End Sub

Private Sub EmailMemo_Click()
On Error GoTo Error_EmailMemo_Click

    Dim strMsg As String
    
    'To open an attached email if present.
    If Me.Emailmemo = "EMAIL ATTACHED: Click Here To View" Then
        'Make sure the EmailLocation field contains a value.
        If IsNull(Me![Emaillocation]) Then
            strMsg = "WARNING! PRINT SCREEN THIS ERROR MESSAGE FOR THE SYSTEM ADMINISTRATOR!" & vbCr & vbCr
            strMsg = strMsg & "Note ID " & Me.SvcNoteID & " indicates an e-mail is attached. However, "
            strMsg = strMsg & "the EmailLocation field is null." & vbCr & vbCr
            strMsg = strMsg & "The attached e-mail is missing."
            MsgBox strMsg
        Else
            Application.FollowHyperlink Me![Emaillocation]
        End If
    Else
        'Do nothing
    End If

Exit_EmailMemo_Click:
    Exit Sub
    
Error_EmailMemo_Click:
    If Err.Number = 16388 Then
        'Ignore it - the user selected Cancel on the popup
    ElseIf Err.Number = 490 Then
        'The file specified filename does not exist. Notify the user.
        strMsg = "WARNING! PRINT SCREEN THIS ERROR MESSAGE FOR THE SYSTEM ADMINISTRATOR!" & vbCr & vbCr
        strMsg = strMsg & "Note ID " & Me.SvcNoteID & " includes a value in EmailLocation of "
        strMsg = strMsg & Me![Emaillocation] & ", but the file does not exist." & vbCr & vbCr
        strMsg = strMsg & "The attached e-mail is missing."
        MsgBox strMsg
    Else
        MsgBox Err.Number & " " & Err.Description
    End If
    Resume Exit_EmailMemo_Click
    
End Sub

bij de verwijzingen moet je wel even de outlook libary selecteren.
 
Michel,

bedankt voor het meedenken, ik heb het nu op een hele andere manier opgelost.
werd me wat te complex.

nu heb ik een button gemaakt, die automatisch een folder aanmaakt (mits niet reeds aangemaakt)
en vervolgens wordt het betreffende record geopend in windows verkenner, hier kan ik vanuit outlook direct mijn mails naar toe slepen.

vanaf het formulier kan ik dezelfde map met dezelfde button ook weer aanroepen.
 
drag en drop

hallo,
ik ben zelf bezig met een database en hierin wil ik ook zo'n drap en drop gedeelte inbouwen.
Die versie met een knop lijkt mij ook wel mooi.
Wil je dat afstaan aan mij?:d
ben
 
Ben hierbij de VBA code,
Maak een button aan op een formulier, via de eigenschappen voer je onderstaande code in bij "klikken", programmacode.

Succes ermee!

Code:
Private Sub openFolder_Click()
On Error GoTo Err_cmbMkDir_Click

Dim DirName As String
Dim DirKlachtID As String
'onderstaand is het netwerk adres van de folder, me.nummer is het klantnummer me.Naam is de klantnaam
DirName = "C:\Klachten\" & Me.Nummer & " " & Me.Naam
DirKlachtID = "C:\Klachten\" & Me.Nummer & " " & Me.Naam & "\" & Me.Id

'eerst wordt gekeken of de folder al bestaat, zo niet wordt deze automatisch aangemaakt.
If Dir(DirName, vbDirectory) = "" Then
MkDir DirName
End If
'nu wordt gekeken of de subfolder al bestaat, zo niet wordt deze automatisch aangemaakt.
If Dir(DirKlachtID, vbDirectory) = "" Then
MkDir DirKlachtID
End If

'windows verkenner wordt gestart en toont de zojuist aangemaakt folder.
Shell "C:\WINDOWS\explorer.exe """ & DirKlachtID & "", vbNormalFocus
Exit Sub


Exit_cmbMkDir_Click:
Exit Sub

Err_cmbMkDir_Click:
MsgBox Err.Description
Resume Exit_cmbMkDir_Click
End Sub
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan