18. maj 2012 - 11:26Der er
35 kommentarer og 1 løsning
trække filer fra outlook til Access
Hi
Jeg har access 2007 Kan i hjælpe:
Jeg ønsker at kunne trække filer fra outlook (Excel,Doc) over i min access DB hvor de placeres i en mappe så de kan nås med en link. Jeg har det i dag så jeg kan flytte dokumenterne fra outlook til en mappe og uplode til Access men jeg ønsker at trække direkte fra outlook til Access
Jeg prøver igen: I outlook har jeg en vedhæftet fil. Dem ønsker jeg trukket over i Access i en tekstbox. Her skal linket til filen gemmes i Access Selve filen skal gemmes i en mappe på disken.
Jeg prøver igen: Ja jeg kan selvfølgelig flytte filer til en mappe det er ikke det jeg spørger om. Jeg ønsker at trække outlooks vedhæftede filer over til en tekstbox i ACCESS 2007. Her skal linket til filen gemmes i Access og selve filen skal saves på disken.
per2edb I'm trying to find out what you can and what you cant do already, because I dont intend waisting my time in telling you something you already know.
If you can already save an attached file to a folder then you must already have most of the code for what you want to do.
If you can do that then I assume you have the path and filename which you now can save in a textbox.
And if we dont understand each other then I think you will have to wait until someone else comes by.
Hej If you can already save an attached file => nej den er ikke savet i en folder på dette tidspunkt. 1) filen trækkes over fra Outlook til access. 2) så spørges der om den skal saves- samt hvor. 3) der svares ja og stien angives, hvorefter den saves på disken 4) Linket til filen saves i access 5) efterfølgende kan et klik på dette link vise filen
Denne metode findes i mange professionelle programmer - benævnt - "træk og slip" MS bruger det også selv.
Det virker desværre ikke!!!! Jeg har lagt nedenfor viste koder i et VBA modul i outlook Herudover oprettet C:\new email Der vises fejl i:
Set myFolder = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFo lderInbox) og If UCase(Right(myFolder.Items(A).Attachments(b).Displ ayName, 3)) = "XLS" Then ----- Outlook ----- Private Sub Application_NewMail()
Dim myFolder As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.application") Set myFolder = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFo lderInbox) Set myitem = myOlApp.CreateItem(olMailItem)
For A = 1 To myFolder.Items.Count If myFolder.Items(A).UnRead = True Then If myFolder.Items(A).Attachments.Count <> 0 Then For b = 1 To myFolder.Items(A).Attachments.Count If UCase(Right(myFolder.Items(A).Attachments(b).Displ ayName, 3)) = "XLS" Then
Set myFolder = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFo lderInbox)
og
If UCase(Right(myFolder.Items(A).Attachments(b).Displ ayName, 3)) = "XLS" Then
----- Access -----
Private Sub Tilbud_Leverandør_Doc_2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim myFolder As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.application") Set myFolder = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFo lderInbox) Set myitem = myOlApp.CreateItem(olMailItem)
For a = 1 To myFolder.Items.Count If myFolder.Items(a).UnRead = True Then If myFolder.Items(a).Attachments.Count <> 0 Then For b = 1 To myFolder.Items(a).Attachments.Count If UCase(Right(myFolder.Items(A).Attachments(b).Displ ayName, 3)) = "XLS" Then
This works. If you cant get it to work than I cant help you.
Curently the code only looks for .docx files. The destination folder must exist, and dont forget the refernce
im myFolder As Outlook.MAPIFolder Dim myOlApp As Outlook.Application Dim myItem As Outlook.MailItem Dim a As Integer Dim b As Integer Dim the_filename As String
Set myOlApp = CreateObject("Outlook.application") Set myFolder = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox) Set myItem = myOlApp.CreateItem(olMailItem)
For a = 1 To myFolder.Items.Count If myFolder.Items(a).UnRead = True Then If myFolder.Items(a).Attachments.Count <> 0 Then For b = 1 To myFolder.Items(a).Attachments.Count If UCase(Right(myFolder.Items(a).Attachments(b).DisplayName, 4)) = "docx" Then the_filename = "C:\new email\recd " & Format(Now(), "dd-mmm-yyyy") & " " & myFolder.Items(a).Attachments(b).DisplayName myFolder.Items(a).Attachments(b).SaveAsFile the_filename
Jeg Fandt: Microsoft office Outlook view Control og Microsoft Outlook 12 object libery
Begge er nu vedhæftet men der kommer fejl i linie 1: Im MyFolder as.....
Private Sub Tilbud_Leverandør_Doc_2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
im myFolder As Outlook.MAPIFolder Dim myOlApp As Outlook.Application Dim myItem As Outlook.MailItem Dim a As Integer Dim b As Integer Dim the_filename As String
Set myOlApp = CreateObject("Outlook.application") Set myFolder = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox) Set myItem = myOlApp.CreateItem(olMailItem) For a = 1 To myFolder.Items.Count If myFolder.Items(a).UnRead = True Then If myFolder.Items(a).Attachments.Count <> 0 Then For b = 1 To myFolder.Items(a).Attachments.Count If UCase(Right(myFolder.Items(a).Attachments(b).DisplayName, 4)) = "pdf" Then the_filename = "C:\new email\recd " & Format(Now(), "dd-mmm-yyyy") & " " & myFolder.Items(a).Attachments(b).DisplayName myFolder.Items(a).Attachments(b).SaveAsFile the_filename
Jeg trækker en pdf fil over fra outlook til access.
You shouldnt have to do that, the code should do it for you.
This question is taking a long time to answer! I cant teach you the basics...
You will need to through the code to see what is happening and it doesnt help that I can get it to work on my PC because its you who needs to get it to work on your PC.
If you cant manage to debug the code then I think you will have to get help elsewhere :o(
Det er en email med en attached pdf fil jeg trækker over til access.
Debug viser: myOlApp = "outlook" myFolder = "indbakke" myItem = "" <= Hvorfor er den Tom ?
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.