FileCopy Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bhughes2187
    New Member
    • Mar 2008
    • 32

    FileCopy Problem

    In my app I am creating, there is a procedure that does a file copy from the local drive to a network share. The issue I am having, is even though I have the share mapped, and I can browse to the share with no problems, when ever the procedure is run, I get a Permission Denied error.

    When I get this error, I click on Debug and find the line causing the error which is my file copy line. If I click continue, the code sequence finishes and the file is copied out to the network share. I have no clue what is causing this issue or how to fix it. Is there a possible way of suppressing the error and having it just continue on with the next line?

    The code procedure is as follows"
    Code:
    'Set data paths. Where file is located and location to copy data
        DestName1 = "X:\PDF\"
        DirName1 = "C:\portfolio\TEMPDATA\"
        nextbookA = Dir(DirName1 & "*.pdf")
       If nextbookA <> "" Then
       FileCopy DirName1 & nextbookA, DestName1 & nextbookA
       Kill DirName1 & nextbookA
       End If
    This line:
    FileCopy DirName1 & nextbookA, DestName1 & nextbookA

    is the line it crashes on
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi. It would undoubtedly be better to find the cause of your error and resolve this. I'm sorry to say I have no more idea what it might be than you.

    As a work around at present you can indeed get VBA to ignore errors; at the top of the sub or function which is doing the copy just add:
    [code=vb]On Error Resume Next[/code]
    If there is an existing On Error statement you can override it with On Error Resume Next just before the copy then insert another version of the original On Error redirect afterwards to ensure that other errors are trapped as necessary.

    -Stewart

    Comment

    • jimatqsi
      Moderator Top Contributor
      • Oct 2006
      • 1290

      #3
      Hi. How have you logged on? Are you logged on as an Administrator? I think the answer will lie in user privileges. Try changing the destination location to be somewhere in your My Documents folder. I bet that will be successful. Meanwhile, I'll review my old posts and replies, because I think I had this same problem, or a very similar one, months ago.

      Jim

      Comment

      • bhughes2187
        New Member
        • Mar 2008
        • 32

        #4
        The machine login uses a name and password that exists on the file server. The share is mapped, I can even have the share open watching for the file to arrive and I still get the error.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32645

          #5
          Please remember to provide a meaningful Title for any threads started (Please Use Appropriate Titles for New Threads!). This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

          ADMIN.

          Comment

          • bhughes2187
            New Member
            • Mar 2008
            • 32

            #6
            Resolved the issue by setting the save path in PDFcreator to the network share. No longer copying from one location to the other.

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              Originally posted by bhughes2187
              In my app I am creating, there is a procedure that does a file copy from the local drive to a network share. The issue I am having, is even though I have the share mapped, and I can browse to the share with no problems, when ever the procedure is run, I get a Permission Denied error.

              When I get this error, I click on Debug and find the line causing the error which is my file copy line. If I click continue, the code sequence finishes and the file is copied out to the network share. I have no clue what is causing this issue or how to fix it. Is there a possible way of suppressing the error and having it just continue on with the next line?

              The code procedure is as follows"
              Code:
              'Set data paths. Where file is located and location to copy data
                  DestName1 = "X:\PDF\"
                  DirName1 = "C:\portfolio\TEMPDATA\"
                  nextbookA = Dir(DirName1 & "*.pdf")
                 If nextbookA <> "" Then
                 FileCopy DirName1 & nextbookA, DestName1 & nextbookA
                 Kill DirName1 & nextbookA
                 End If
              This line:
              FileCopy DirName1 & nextbookA, DestName1 & nextbookA

              is the line it crashes on
              1. Are you aware that your code will only copy the 1sf File with a *.pdf extension in C:\portfolio\TE MPDATA\?
              2. If you attempt to copy a File that is currently Open, you will receive an Error, and the FileCopy operation will fail. Couold this be the case?

              Comment

              • bhughes2187
                New Member
                • Mar 2008
                • 32

                #8
                No that wasn't the case. The full PDF file was created and sitting in c:\portfolio\te mpdata. Where the error "Permission Denied" was happening was on copying the completed file to X:\PDF

                Comment

                Working...