2016-07-26 213 views
-1

你能幫我請創建一個從磁盤搜索文件的宏, 請看:C:\Etikety\Stitky\。 我搜索一個名稱,其中包含的單元格C2 和文件類型是.lbe
當文件發現打印它。 我會將這部分代碼實現到此代碼中。謝謝答覆excel宏VBA搜索和打印文件


Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 
Sub zadat() 

Dim reg, check As String 
Dim i, j, done As Integer 
reg = Cells(2, 3).Value 
check = Cells(4, 3).Value 

If check = "True" Then 

    i = 2 
    j = 1 
    done = 0 
    Do While Sheets("data").Cells(i, j) <> "" 
     If Sheets("data").Cells(i, j) = reg Then 
      done = Sheets("data").Cells(i, j + 3) 
      done = done + 1 
      Sheets("data").Cells(i, j + 3) = done 
      Exit Do 
     End If 
     i = i + 1 

    Loop 
Else 
    MsgBox ("Chyba, oprav!!!") 
End If 

Cells(3, 3) = "" 

Cells(3, 3).Select 
ActiveWindow.ScrollRow = Cells(1, 1).row 

End Sub 
+0

http://stackoverflow.com/questions/20687810/vba-macro-that-search-for -file-in-multiple-subfolders – Slai

回答

1

編輯,並嘗試下面的代碼根據自己的需要:

Sub find_N_print() 
    Dim filePath As String 
    filePath = "C:\Etikety\Stitky\" & Range("C2").Value & ".lbe" 
    file = Dir(filePath) 
    If file <> "" Then 
     Application.PrintOut Filename:=filePath & file 
    End If 
End Sub 
+0

嗨,請你能用我的代碼實現這部分代碼嗎?非常感謝你 –