2012-06-27 51 views
0

我寫在vb中,並使用excels參數將.xls文檔轉換爲pdf。該進程正常工作,因爲我正在使用一個字符串。我需要知道的是以某種方式循環訪問源文件夾,然後將該文件夾中的所有文件轉換爲pdf並放入導出文件夾中,保留原始文件名。雖然我知道你需要它在這個行業有一個堅實的基礎,但循環對我的編程存在嚴重的危害。VB循環和Excel

例:

Dim excelApplication As ApplicationClass = New ApplicationClass() 
    Dim excelWorkbook As Workbook = Nothing 
    Dim paramSourceBookPath As String = "C:\My_Projects\Testing\filename.xls" 
    Dim paramExportFilePath As String = "C:\My_Projects\Testing\filename.pdf" 

在此先感謝。

回答

0

試試這個:

Dim dir As New IO.DirectoryInfo(path) 
    Dim files As IO.FileInfo() = dir.GetFiles("*.xls") 
    For Each file In files 
     'Do Something 
    Next