VBA 1004 错误 应用程序定义或对象定义错误
Sub SETUP_DROP_TABLE()
Dim RowPos, ColPos As Integer
Dim TxtFilePath, TBName As String
Dim FS, TextFile
Set WS = Worksheets("Sheet1")
TxtFilePath = ThisWorkbook.Path & "\table.txt"
Set FS = CreateObject("Scripting.FileSystemObject")
Set TextFile = FS.CreateTextFile(TxtFilePath, True)
MsgBox "路径:" & TxtFilePath
RowPos = 2
ColPos = 1
Do
If WS.Cells(RowPos, ColPos) = "SEQUENCE NAME:aaaaa, 1~99999, recycle" Then
Exit Do
End If
TBName = WS.Cells(RowPos, ColPos)
If TBName <> "" Then
TextFile.WriteLine ("DROP TABLE " & TBName & " CASCADE CONSTRAINTS;")
End If
RowPos = RowPos + 1
Loop
TextFile.Close
End Sub