【发布时间】:2013-02-21 05:37:07
【问题描述】:
在按钮点击下有一段代码可以将工作簿内容保存为txt文件
代码:
Private Sub CommandButton1_Click()
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object
Dim strOutputFileName
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\Documents and Settings\bera02a\Desktop\Arun_TAT_Testing_orig_14022013.xls")
For Each xlSheet In xlBook.Worksheets
strOutputFileName = "C:\Documents and Settings\bera02a\Desktop\" & xlSheet.Name & ".txt"
xlSheet.SaveAs Filename:=strOutputFileName, FileFormat:=xlUnicodeText
Next
xlApp.Quit
End Sub
工作簿中的原始行:
create table abc as select rpt2_id, rpt2_usgcount, rpt2_usgdate, rpt2_usgmins from rpt2 where rpt2_id = 'xyz;
输出为:
"create table abc as select rpt2_id, rpt2_usgcount, rpt2_usgdate, rpt2_usgmins from rpt2 where rpt2_id = 'xyz;"
输出的开头和结尾都带有双引号,并且仅用于工作簿中的插入和创建语句。
谁能帮我不要在输出中得到那个引号?
【问题讨论】:
-
peter 上次帮助我解决了与 excel 相关的解决方案。如果他也可以帮助我
-
请遵循@SiddharthRout 的建议并在此处查看:msdn.microsoft.com/en-us/library/office/… 祝你好运!