0
我有一个包含多个dbf文件的“test”文件夹。我想要vba在excel文件中打开它们并将它们(以excel格式)保存在保存相同dbf文件名的另一个文件夹中。打开文件夹中的所有dbf文件并将它们另存为excel到另一个文件夹中
我在网上发现了这段代码,并试图使用这段代码来满足我的需求,但它不起作用。错误信息:
“的功能子没有定义”
...请调查一下。
Sub test()
Dim YourDirectory As String
Dim YourFileType As String
Dim LoadDirFileList As Variant
Dim ActiveFile As String
Dim FileCounter As Integer
Dim NewWb As Workbook
YourDirectory = "c:\Users\navin\Desktop\test\"
YourFileType = "dbf"
LoadDirFileList = GetFileList(YourDirectory)
If IsArray(LoadDirFileList) = False Then
MsgBox "No files found"
Exit Sub
Else
' Loop around each file in your directory
For FileCounter = LBound(LoadDirFileList) To UBound(LoadDirFileList)
ActiveFile = LoadDirFileList(FileCounter)
Debug.Print ActiveFile
If Right(ActiveFile, 3) = YourFileType Then
Set NewWb = Application.Workbooks.Open(YourDirectory & ActiveFile)
Call YourMacro(NewWb)
NewWb.SaveAs YourDirectory & Left(ActiveFile, Len(ActiveFile) - 4) & ".xlsx"
NewWb.Saved = True
NewWb.Close
Set NewWb = Nothing
End If
Next FileCounter
End If
End Sub
@katz ...是我的确COPIE它从那里......那些必要的?以下部分的目的是什么? – Navin
@Navin是的功能是必要的代码,只是尝试它 –
@ katz..Yes它的工作......最后一件事请...我必须改变哪部分,以便保存excel文件在一个不同的文件夹(例如在c:\ Users \ navin \ Desktop \ test \转换为excel) – Navin