+ Reply to Thread
Results 1 to 4 of 4

File retrieved using variables can't be found

  1. #1
    Registered User
    Join Date
    11-06-2013
    Location
    NC
    MS-Off Ver
    Excel 2007
    Posts
    42

    File retrieved using variables can't be found

    Hello everyone,

    I have written a macro that saves a file name to a drive using variables. That part of the macro works just fine. I have also written a macro to retrieve the same file using the same variables but I continue to get an error message that the file can't be found and recommends I check my spelling or try a different path. I am using a serial number followed by an extra digit as the variables, example the serial number 12 Build 2 is saved as SN 12 BLD 2. However when I receive the error message, the message adds a ' to the last digit. The message would then say SN 12 BLD 2'. I am not sure this is the problem but it does look suspicious.

    I have checked the formatting of the cell I am using to pick up the build number and it is a normal "general" format with no additional text added that I can see. And again, this same cell and format is used to save the original file with no issues.

    Can anyone tell me what I might be doing wrong. I have written a very similar macro in the past without running into this problem.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: File retrieved using variables can't be found

    Can you attach your workbook as an example?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    11-06-2013
    Location
    NC
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: File retrieved using variables can't be found

    This macro works
    Sub SAVE()
    '
    ' SAVE Macro
    Let SERIALNUMBER = Range("C5")
    Let Build = Range("C7")
    spath = "\\C:\CUSTOMER SERVICE PROJECT\MRO DATA\INSPECTION DATA\"
    ActiveWorkbook.SaveAs (spath & "SN " & SERIALNUMBER & " BLD " & Build)

    This one doesn't

    Sub RETRIEVE()
    '
    ' RETRIEVE Macro
    '
    Let SERIALNUMBER = Range("C5")
    Let Build = Range("C7")
    spath = "\\C:\CUSTOMER SERVICE PROJECT\MRO DATA\INSPECTION DATA\"
    Workbooks.Open (spath & "SN " & SERIALNUMBER & " BLD " & Build)
    End Sub

  4. #4
    Registered User
    Join Date
    11-06-2013
    Location
    NC
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: File retrieved using variables can't be found

    I was able to resolve this problem by adding a .xlsm to the name when I saved the file and when I retrieved it. I don't know why it didn't work the other way but now it does.

+ 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. Copying file but receive an Run-time error'53' - File not found
    By jeffreybrown in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-02-2013, 06:40 PM
  2. Excel 2010 file with VBA save and send code works-but file can't be found.
    By carlton.clay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2013, 09:46 AM
  3. [SOLVED] Message (in one window) for each file found/not found
    By kboy1289 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-08-2013, 04:03 PM
  4. macro that finds variables in one column and enters values if variables found
    By xln00b in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-07-2010, 08:22 AM
  5. Can the author of an .XLS be found and retrieved ?
    By HTTC guy in forum Excel General
    Replies: 1
    Last Post: 07-14-2006, 12:05 PM

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