在这里,我使用的代码我尝试运行 cmdline 来创建 txt 文件,然后将其导入到 excel 中,它一直在说“这个对象不支持这个属性或方法”
我不知道在哪里修复它我现在卡住了
Sub ImportTextFile()
Dim rPaht As String
Dim rFileName As String
Dim rPaht1 As String
Dim rFileName1 As String
txtFpath = Sheet1.Range("a1").Value
Filesum = "type unixinv* > summary2.txt"
ChDrive "D"
RSP = Shell(Environ$("COMSPEC"), vbNormalFocus)
Application.Wait Now + TimeValue("00:00:03")
SendKeys "CD " & txtFpath & "{ENTER}", True
Application.Wait Now + TimeValue("00:00:04")
SendKeys Filesum & "{ENTER}", True
Application.Wait Now + TimeValue("00:00:04")
SendKeys "exit " & "{ENTER}", True
rPaht = Sheet1.Range("a1")
rFileName = Sheet1.Range("a2")
Sheet1.Cells.Clear
With Sheet4.QueryTables.Add(Connection:= _
"TEXT;" & rPaht & "\" & rFileName & ".txt", Destination:=Sheet1.Range("$A$4"))
.Name = Sheet1.Range("C8").Value
.TextFilePlatform = 874
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileOtherDelimiter = ":"
.Refresh BackgroundQuery:=False
End With
Sheet1.Range("a1") = rPaht
Sheet1.Range("a2") = rFileName
End Sub