简体   繁体   English

Excel VBA代码导致我的工作表显示为行话

[英]Excel VBA code is causing my worksheets to appear as jargon

I currently am using a VBA macro that I found here on stack over flow. 我目前正在使用一个VBA宏,我在堆栈上找到了流量。 The problem is when I run it it saves all the data into a separate excel sheet but when i open it it appears as "jargon" in other words unreadable type. 问题是,当我运行它时,它将所有数据保存到一个单独的Excel工作表中,但当我打开它时,它显示为“行话”,换句话说是不可读的类型。 This is the "Save code" 这是“保存代码”

'Save the new workbook, and close it
wb.SaveAs ThisWorkbook.Path & "\test" & WorkbookCounter
wb.Close

The way I am currently running the code is that it separates my excel sheets into different spread sheets by rows of 250. Everything works but when I open the saved documents it says that this file format is unacceptable to Excel. 我目前运行代码的方式是它将我的Excel工作表分成250行的不同电子表格。一切正常但是当我打开保存的文档时,它表示这种文件格式对Excel来说是不可接受的。 Then I try importing it and I get an error. 然后我尝试导入它,我收到一个错误。 Here is a snap shot of the way it appears in my screen. 这是它在我的屏幕中出现的方式的快照。 Also here is the file name: built.list\\test.xls39 这里还有文件名:built.list \\ test.xls39

Your workbook counter always ends in a number, Windows and Excel use the file extension to determine file-type, so an '.xls39' file is unrecognisable. 您的工作簿计数器始终以数字结尾,Windows和Excel使用文件扩展名来确定文件类型,因此“.xls39”文件无法识别。 Try: 尝试:

wb.SaveAs _
    Filename:=ThisWorkbook.Path & "\test" & WorkbookCounter & ".xls" _
    FileFormat:=XlFileFormat.xlExcel8

'Use xlOpenXMLWorkbook for the .xlsx format

(Use space followed by underscore to separate lines in VBA) (使用空格后跟下划线分隔VBA中的行)

Or make sure WorkbookCounter ends in .xls and not a number. 或者确保WorkbookCounter以.xls而不是数字结尾。

(Edit: For other formats, please look in the References dialog in Excel VBA Editor) (编辑:对于其他格式,请查看Excel VBA编辑器中的“参考”对话框)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM