Consulting

Results 1 to 2 of 2

Thread: Access Error: You dont have appropriate permission to perform this operation

  1. #1

    Question Access Error: You dont have appropriate permission to perform this operation


    I am having trouble saving an outlook attachment to a folder using VBA. It was working before when I was saving it to a network drive folder but now I want it to save to my documents folder and I am getting an error that says:

    Run time error '-2147024891 (80070005)':
    Cannot save the attachment. You don't have the appropriate permission to perform this operation.

    Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
    Dim objAtt As Outlook.Attachment
    Dim saveFolder As String
    Dim dte As Date
    Dim m As String
    Dim d As String
    Dim y As String
    
     
    saveFolder = "C:\Users\495170\Documents\Daily Aged Memo auto-send"
    dte = Now
    m = month(dte)
    d = Day(dte)
    y = Year(dte)
    
            
        For Each objAtt In itm.Attachments
                objAtt.DisplayName = "Daily Aged Memo - " & m & "-" & d & "-" & y & ".xls"
                objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
                Set objAtt = Nothing
         Next
    End Sub
    Last edited by Bob Phillips; 02-20-2015 at 10:47 AM. Reason: Added code tags and moved forum

  2. #2
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    Is it Documents or MyDocuments?

    Since you have not mentioned any troubleshooting.
    Can you open the folder by pasting the path, without quotes, into the address bar of Windows Explorer?
    Can you save a document manually?
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

Posting Permissions

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