+ Reply to Thread
Results 1 to 4 of 4

Microsoft excel cannot access the file C:\... The file name or path

Hybrid View

HraHuuh Microsoft excel cannot access... 08-02-2012, 05:37 AM
JosephP Re: Microsoft excel cannot... 08-02-2012, 05:38 AM
HraHuuh Re: Microsoft excel cannot... 08-02-2012, 05:43 AM
JosephP Re: Microsoft excel cannot... 08-02-2012, 05:48 AM
  1. #1
    Registered User
    Join Date
    06-19-2012
    Location
    Finland
    MS-Off Ver
    Excel 2007
    Posts
    14

    Microsoft excel cannot access the file C:\... The file name or path

    Hey!
    Ive made macro which open new workbook and then save it to your computer. It works well using my computer. Then I sent it to my friend that he could use it. When he runs the macro this error comes up " Microsoft excel cannot access the file C:\... The file name or path doesnt exist, the file is being used by another program.. " etc..
    Could someone help me with this error?

    Br. Antti

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Microsoft excel cannot access the file C:\... The file name or path

    need to see the code to fix it ;-)
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    06-19-2012
    Location
    Finland
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Microsoft excel cannot access the file C:\... The file name or path

    Here is the critical part of code
    Sub Button25_Click()
    
    Dim sPath As String
    Dim wk As Workbook
    sPath = "C:\CompetitorInformation.xls"
    Application.DisplayAlerts = False
    
    
    If FileOrDirExists(sPath) Then
        Workbooks.Open Filename:="c:\CompetitorInformation.xls"
        Workbooks("CompetitorInformation.xls").Close
        Kill "C:\CompetitorInformation.xls"
        Set wk = Workbooks.Add
        wk.SaveAs Filename:="C:\CompetitorInformation.xls"
    Else
        Set wk = Workbooks.Add
        wk.SaveAs Filename:="C:\CompetitorInformation.xls"
    End If

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Microsoft excel cannot access the file C:\... The file name or path

    what's the point of opening and closing and then deleting the workbook? it appears you could simply use
    Sub Button25_Click()
    
    Dim sPath As String
    Dim wk As Workbook
    sPath = "C:\CompetitorInformation.xls"
    Application.DisplayAlerts = False
    
        Set wk = Workbooks.Add
        wk.SaveAs Filename:=sPath
    though perhaps the user does not have permission to write to the root of C

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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