2014-10-19 6 views
-6
나는 송장 자동화 프로젝트에 참여하고

, 여기에 그 코드를 설계했다 수도 있지만 파일을 보여주는 코드 실행 시간 오류와 문제에 직면하고있다 나는 또한 여전히 동일하지만 대한 변경 위치에 시도되는 Workbooks.Open ("C:\invoicesample\invoice.xlsx")에 따라 업데이트 된 코드를런타임 오류 1004 "파일

+0

나는 당신이 다른 대답. 왜 내 글을 무시하는 특별한 이유가 있습니까? –

+0

죄송합니다 Siddharth 나는이 문제에서 나를 도울하시기 바랍니다 어떤 아이디어가 있다면 당신의 의견을 확인하지 않았다 – biomillind

답변

0

을이되어 노력하고 (C : \ invoicesample \ invoice.xlsx) 대상 파일 확인되지는 것은 볼 수 있습니다

.
Option Explicit 
Private Sub CommandButton1_Click() 

    Dim outward As Variant 
    Dim Invoice As Variant 
    Dim resources As String 
    Dim qty As String 
    Dim Vat As String 
    Dim unitprice As String 
    Dim kindattn As String 
    Dim name As String 
    Dim address As String 
    Dim city As String 
    Dim r As Long 
    Dim state As String 
    Dim zip As String 
    Dim mobileno As Variant 
    Dim lastrow As Long 
    Dim phonenumber As String 
    Dim bankid As String 
    Dim path As String 
    Dim myfilename As String 
    Dim mydate As String 
    Dim servicetax As String 
    Dim strfilepath As String 
    Dim total As Long 

    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 
     kindattn = Sheets("invoiceinfo").Cells(r, 12).Value 
     name = 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 
     strfilepath = "C:\invoicesample\invoice.xlsx" 

     If Dir(strfilepath) = "" Then 
      MsgBox " file not avilable on path ", vbCritical 
     Else 
      Workbooks.Open (strfilepath) 
      ActiveWorkbook.Sheets("invoice").Activate 
      ActiveWorkbook.Sheets("invoice").Range("D9").Value = bankid 
      ActiveWorkbook.Sheets("invoice").Range("D11").Value = kindattn 
      ActiveWorkbook.Sheets("invoice").Range("D12").Value = name 
      ActiveWorkbook.Sheets("invoice").Range("D13:H14").Value = address 
      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 = phonenumber 
      ActiveWorkbook.Sheets("invoice").Range("M14").Value = outward 
      ActiveWorkbook.Sheets("invoice").Range("M15").Value = Invoice 
      ActiveWorkbook.Sheets("invoice").Range("E20:H20").Value = resources 
      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 
      Date = Format(mydate, "DD_MM_YYYY") 

      ActiveWorkbook.SaveAs Filename:=path & Invoice & "-" & Date & "-" & name & ".Xlsx" 
      myfilename = ActiveWorkbook.FullName 
      Application.DisplayAlerts = True 
      SetAttr myfilename, vbReadOnly 
      'ActiveWorkbook.PrintOut Copies:=1 

      ActiveWorkbook.Close savechanges:=False 
     End If 
nextrow: 
     Next r 


End Sub 
+0

여전히 보여주는 오류, 내가 당신에게 모양과 문제가 완전한 파일을 보낼 수 – biomillind

+0

물론! Dropbox와 같은 파일 공유 웹 사이트에서 전체 파일을 공유하고 다운로드 링크를 알려주십시오. 나는 그것을 볼 수있다. –

+0

가능하면 이메일 ID를 통해 보낼 수 있습니다 – biomillind