|
我将一个EXEcel中的模块导入到access中,运行后,总是提示方法和成员为找到,确定后,就直接跑到getopenfilename这个地方,怎么解决啊?高手指点一下,源码如下:
Sub renamecsv2txt()
Dim rc_files As Variant ' Var for the Varient
' Holds the files that the users selects
Dim a_FileName As String ' Holds the name of a String
Dim FoxFiles As Variant 'Holds the DBF files the user selected.
Dim FoxFile As String 'Holds one of the DBF files from FoxFIles.
Dim FoxFilename As String 'Name of the DBF file ex: Filename.dbf
Dim WorkingPath As String 'Path of the DBF files the user selected.
Dim FileCount As Long 'Holds the number of files the user selected.
Dim WorkingFile As String 'Holds the temporary name of the DBF file being parsed.
'The working file is a copy of the actual file being parsed
' with a new name. The new name is WorkingPath + TempFileName
Dim b_isArray As Boolean
Dim newFileName As String
On Error GoTo ExitSub
' MsgBox ("I just wanted to say hello", vbOKOnly, "Sanity Check MsgBox", , "I think this is the content" , Context As Variant
'Select Files
rc_files = Array()
rc_files = Application.GetOpenFileName("csv文本文件 (*.csv), *.*", _
1, "Select file to ReName", "Select", True)
If (UBound(rc_files) > 0) Then
FileCount = UBound(rc_files)
On Error GoTo ErrHandler
' For all the files in the list
For X = 1 To FileCount
a_FileName = rc_files(X)
newFileName = GetFileName(a_FileName) & ".txt"
' newFileName = a_FileName & "txt"
' Rename the files
Name a_FileName As newFileName
Next X
FileCount = FileCount + 1
End If
ExitSub:
Exit Sub
ErrHandler:
MsgBox Error
Exit Sub
End Sub
Public Function GetFileName(FullFileName As String) As String
Dim X As Integer
X = Len(FullFileName)
GetFileName = Left(FullFileName, X - 4)
End Function |
|