+ Reply to Thread
Results 1 to 5 of 5

Receiving Runtime Error 1004 -Cannot Access file

  1. #1
    Registered User
    Join Date
    08-15-2013
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Receiving Runtime Error 1004 -Cannot Access file

    Hey All -I am hoping someone can help me

    I am a novice (self taught/learning) so i have been grabing code from all over to build my Macro

    Below is part of the macro -it prompts the user to select the file the macro will use to update our master price workbook

    I then want to save the file elsewhere so the original file isn't modified.

    I keep getting a Runtime Error 1004 -Excel cannot access the file

    I can't work out why?

    I know it will be my lack of formal knowledge causing the issue.

    If someone can help -please explain as if i am a 2 year old not 46 lol

    thanks
    Dean



    MsgBox "Please Select MicroJets New Price Book"
    fName = Application.GetOpenFilename(FileFilter:="Excel Files (*.XLSX), *.XLSX", Title:="Select File To Be Opened")
    If fName = False Then Exit Sub
    'Set bk1 = Workbooks.Open(fName)
    savefilename = Mid(fName, InStrRev(fName, "\") + 1)
    MsgBox savefilename
    Set bk1 = Workbooks.Open(savefilename)
    bk1.SaveCopyAs filename:= _
    "C:\Users\Public\Public Documents\Work-Macros\" & savefilename ', FileFormat:=51, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
    Last edited by Dean Staples; 08-30-2013 at 09:24 PM.

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

    Re: Receiving Runtime Error 1004 -Cannot Access file

    2 issues
    first this
    Please Login or Register  to view this content.
    oughta be
    Please Login or Register  to view this content.
    and second savecopyas only accepts a filename argument
    Josie

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

  3. #3
    Registered User
    Join Date
    08-15-2013
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Receiving Runtime Error 1004 -Cannot Access file

    Hey Joseph/Josie

    Thks for the reply

    I changed the set command

    I have commented out the arguments for savecopyas already -they are only there because i started with saveas


    But unfortunately

    I still recieve the Runtime Error -

    the Error does show the path & file name correctly

    -I was thinking it is because the macro has the workbook active that is triggering the error -but only guessing & don't have the knowledge to work it out

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

    Re: Receiving Runtime Error 1004 -Cannot Access file

    which line causes the error?

  5. #5
    Registered User
    Join Date
    08-15-2013
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Receiving Runtime Error 1004 -Cannot Access file

    Ok -Once i turned off events & alert -and changed file access to shared ?? it now works

+ 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. [SOLVED] Runtime-error '1004' cannot access the file, depending on the computer
    By yuichi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-03-2012, 06:05 PM
  2. Excel - Access 1004 Runtime Error PLEASE HELP!!!
    By jamesgarf in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2012, 01:59 PM
  3. Receiving runtime error 1004: Method 'Range' of object '_Worksheet' failed
    By DrShocktopus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-28-2010, 10:39 AM
  4. Runtime error '1004': cannot access...
    By rsford31 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2010, 03:58 PM
  5. File Name Causes Runtime Error 1004
    By Robert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-10-2005, 10:55 AM

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