+ Reply to Thread
Results 1 to 7 of 7

Run time error 1004 file could not found on specify location

  1. #1
    Registered User
    Join Date
    01-29-2014
    Location
    Pune
    MS-Off Ver
    2010
    Posts
    6

    Post Run time error 1004 file could not found on specify location

    Hello everyone,

    I am trying to automate invoice process by using VBA code but at the time of using this I am facing problem of Run time error 1004 file could found at location.

    I am facing problem on below code

    Workbooks.Open ("D:\Contactdetails\desktopfiles\invoicesample\invoice.xlsx")

    As I have checked all file name given by me and location, everything is okey but still I am facing this problem. Can anyone help me out this problem?

    Thanks in advance...

    Mady

    Code :

    Private Sub CommandButton1_Click()
    Dim qty As String
    Dim unitprice As String
    Dim bankname As String
    Dim address As String
    Dim city As String
    Dim r As Long
    Dim state As String
    Dim zip As String
    Dim path As String
    Dim myfilename As String
    Dim mydate As String
    lastrow = Sheets("invoiceinfo").Range("A" & Rows.Count).End(xlUp).Row
    r = 6
    For r = 6 To lastrow
    If Cells(r, 21).Value = "done" Then GoTo nextrow

    outward = Sheets("invoiceinfo").Cells(r, 3).Value
    Invoice = Sheets("invoiceinfo").Cells(r, 4).Value
    Resources = Sheets("invoiceinfo").Cells(r, 6).Value
    qty = Sheets("invoiceinfo").Cells(r, 7).Value
    unitprice = Sheets("invoiceinfo").Cells(r, 8).Value
    Vat = Sheets("invoiceinfo").Cells(r, 9).Value
    Servicetax = Sheets("invoiceinfo").Cells(r, 10).Value
    Total = Sheets("invoiceinfo").Cells(r, 11).Value
    kindattn = Sheets("invoiceinfo").Cells(r, 12).Value
    bankname = Sheets("invoiceinfo").Cells(r, 13).Value
    address = Sheets("invoiceinfo").Cells(r, 14).Value
    city = Sheets("invoiceinfo").Cells(r, 15).Value
    state = Sheets("invoiceinfo").Cells(r, 16).Value
    zip = Sheets("invoiceinfo").Cells(r, 17).Value
    mobileno = Sheets("invoiceinfo").Cells(r, 18).Value
    phonenumber = Sheets("invoiceinfo").Cells(r, 19).Value
    bankid = Sheets("invoiceinfo").Cells(r, 20).Value

    Cells(r, 21).Value = "done"
    Application.DisplayAlerts = False
    Workbooks.Open ("D:\Contactdetails\desktopfiles\invoicesample\invoice.xlsx")
    ActiveWorkbook.Sheets("invoice").Activate
    ActiveWorkbook.Sheets("invoice").Range("D9").Value = bankid
    ActiveWorkbook.Sheets("invoice").Range("D11").Value = kindattn
    ActiveWorkbook.Sheets("invoice").Range("D13:H14").Value = Address1
    ActiveWorkbook.Sheets("invoice").Range("D15").Value = city
    ActiveWorkbook.Sheets("invoice").Range("F15").Value = state
    ActiveWorkbook.Sheets("invoice").Range("H15").Value = zip
    ActiveWorkbook.Sheets("invoice").Range("H15").Value = mobileno
    ActiveWorkbook.Sheets("Invoice").Range("D17").Value = Phoneno
    ActiveWorkbook.Sheets("invoice").Range("M14").Value = Outwardno
    ActiveWorkbook.Sheets("invoice").Range("M15").Value = Invoiceno
    ActiveWorkbook.Sheets("invoice").Range("E20:H20").Value = resource
    ActiveWorkbook.Sheets("invoice").Range("J20").Value = qty
    ActiveWorkbook.Sheets("invoice").Range("L20").Value = unitprice
    ActiveWorkbook.Sheets("invoice").Range("M20").Value = Total
    ActiveWorkbook.Sheets("invoice").Range("M38").Value = Vat
    ActiveWorkbook.Sheets("invoice").Range("M39").Value = Servicetax

    path = "D:\contact details\"
    mydate = Date
    mydate = Format(mydate, "DD_MM_YYYY")
    ActiveWorkbook.SaveAs Filename:=path & Invoice & "-" & Date & "-" & bankname & ".Xlsx"
    myfilename = ActiveWorkbook.FullName
    SetAttr myfilename, vbReadOnly
    Application.DisplayAlerts = True
    'ActiveWorkbook.PrintOut Copies:=1


    Activewrokbook.Close savechanges:=False

    nextrow:

    Next r


    End Sub

  2. #2
    Registered User
    Join Date
    01-29-2014
    Location
    Pune
    MS-Off Ver
    2010
    Posts
    6

    Re: Run time error 1004 file could not found on specify location

    is there anyone who can help me out the problem

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,090

    Re: Run time error 1004 file could not found on specify location

    Welcome to the forum.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    However, in the meantime, I WILL respond, although strictly I shouldn't. That's simply to save us both some time.

    You really do need to check that the folder structure is correct and that the file is present and the file name is spelled correctly. Given the coding, I suspect that will not be the case.

    Assuming you do find and fix the anomaly, your code is unlikely to work because many of your variables are not defined. And, when they are defined such that the code will compile, you will discover that the variable names used at different stages of the code don't match. So you store something in one variable but later use a variable with a slightly different name.

    The following code will compile but, as I say, it is unlikely to give you what you expect or hope for.

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    01-29-2014
    Location
    Pune
    MS-Off Ver
    2010
    Posts
    6

    Re: Run time error 1004 file could not found on specify location

    Thanks for the Helped, actually i have defined all mentioned variable by you but at the time of sending post i have removed them cause i have problem on on below code i.e.


    Workbooks.Open ("D:\Contactdetails\desktopfiles\invoicesample\invoice.xlsx")

    which showing error of run time 1004.


    Please help me to solve this problem
    Last edited by mpatil; 10-16-2014 at 03:48 PM.

  5. #5
    Registered User
    Join Date
    01-29-2014
    Location
    Pune
    MS-Off Ver
    2010
    Posts
    6

    Re: Run time error 1004 file could not found on specify location

    As below is coding of invoice automation.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-29-2014
    Location
    Pune
    MS-Off Ver
    2010
    Posts
    6

    Re: Run time error 1004 file could not found on specify location

    As i have checked all my folder structure and file name everything is okey and nothing is misspelled, Waiting for your reply

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,090

    Re: Run time error 1004 file could not found on specify location

    If the folder structure is correct, the file exists in the lowest level folder, and the file name is spelled correctly, the file should open OK.

    Interestingly, your workbook open is:
    Please Login or Register  to view this content.
    However, later in your code, you refer to:
    Please Login or Register  to view this content.

    I cannot help you with this. I am convinced that it is a problem with the folder structure. The code itself looks OK.


    Please note: if you go back and edit earlier posts in the thread, it disrupts the flow of the thread and can be very confusing for everyone.

    Regards, TMS

+ 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] run time error 1004 no cells were found
    By iwannabakat in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2014, 04:13 PM
  2. Run-time error '1004': No cells were found
    By tirk82 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2012, 12:48 PM
  3. [SOLVED] Run Time Error '1004' File Could Not Be Found
    By gyclone in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2010, 02:06 AM
  4. Run Time Error 1004: File not found
    By rajasekhar28 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2010, 02:34 PM
  5. Run-time error '1004':File not found
    By DomV in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-09-2009, 10:26 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