+ Reply to Thread
Results 1 to 4 of 4

VBA Code - File Path Error

  1. #1
    Registered User
    Join Date
    10-28-2014
    Location
    Hickory, NC
    MS-Off Ver
    2013
    Posts
    4

    VBA Code - File Path Error

    I am having a problem with VBA code related to the file path name. In Macro1 - the files are located on the C: drive with no folders and it works. In Macro2 - the files are in folders as shown in code below and does not work.

    Please help - I need someone to show me the code to allow the file path to be work in Macro2. I am not sure if the spaces or "-" in the file path name are a problem.

    Thanks, Marc B.


    'Macro1 - working
    Sub
    Workbooks("LH - COA - Current.xlsm").Worksheets("COA - final").Range("B6:K200").Copy
    Workbooks.Open("C:\COA.xlsm").Worksheets("CC-COA-Expense").Range("B6").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
    Workbooks("COA.xlsm").Close SaveChanges:=True
    End Sub


    'Macro2 - not working - file path error
    Sub
    Workbooks("LH - COA - Current.xlsm").Worksheets("COA - final").Range("B6:K200").Copy
    Workbooks ("C:\Users\Marc\Desktop\In-Rhythm\- Life House\LifeHouse - Credit Card Master\LH - CC - Templates\2 LH-CC-Master\LH - CC - Angela Capito.xlsm")
    Application.CutCopyMode = False
    Workbooks("C:\Users\Marc\Desktop\In-Rhythm\- Life House\LifeHouse - Credit Card Master\LH - CC - Templates\2 LH-CC-Master\LH - CC - Angela Capito.xlsm").Close SaveChanges:=True
    End Sub

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA Code - File Path Error

    Check your spelling, spaces, and non-alphabetic characters to be sure they are correct. Be sure your directory exists in that file path. Be sure your file extension , in this case .xlsm, is correct. Other than that, the code looks OK.

  3. #3
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: VBA Code - File Path Error

    If you looked at the code, there's missing command in the second macro, you probably replaced it mistakenly.
    You have Open, and PasteSpecial in the first macro.
    Nothing on the second.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA Code - File Path Error

    Good catch, millz. Also, there is no paste action taken on a sheet within that workbook if it does open. The previous line of code copies and is just hanging there with nowhere to go.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Kill command & Path/File access error (Error 75)
    By bongaan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-06-2021, 08:21 PM
  2. Run-time error '75' - path/file access error
    By ewood20 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2015, 09:36 AM
  3. Path/File access error & Can't load or unload this object (Error 361)
    By WilliamWu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-28-2014, 12:05 PM
  4. Run time error 75 (Path/File Access Error) - Excel 2007 on XP SP3
    By Portuga in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-30-2014, 10:39 AM
  5. Code to list the folder path and sub folder path of a specific file
    By kalai1587 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2013, 03:51 AM
  6. [SOLVED] Run time error 75 (Path/File Access Error)
    By Riggers in forum Excel Programming / VBA / Macros
    Replies: 44
    Last Post: 03-05-2012, 04:51 PM
  7. Error 75 File/Path access error, sometimes Error 1004
    By smokebreak in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-16-2011, 02:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1