将TXT文本文件数据转换为Excel文件,转换后能正常打开Excel文件。
Private Sub Command1_Click()
Dim str1 As String
Dim str2 As String
CDl.Filter = "TXT文件|*.txt"
CDl.ShowOpen '打开对话框
str1 = CDl.FileName
Print str1
Open str1 For Binary As #1
str1 = Input(LOF(1), 1)
Close #1
CDl.Filter = "Excel文件|*.xls"
CDl.ShowSave '保存对话框
str2 = CDl.FileName
Open str2 For Output As #2
Print #2, str1
Close #2
End Sub