1

当通过 VBA 在工作簿中完成某些操作并通过 VBA 保存时,当我尝试打开保存的文件时,表格、颜色和图表没有出现。
我已经为某些工作簿中的数据创建了一个图表,它正在工作。
但是,如果我保存或另存为具有图表的工作簿,当我尝试再次打开时,没有显示应用于某些行的图表、表格和颜色,只显示纯数据。

源工作簿为 .csv 格式。我将其保存为 .xlsx 和 .csv。

ActiveWorkbook.SaveAs "C:\Documents and Settings\Desktop\finaloutput11.csv"
ActiveWorkbook.Close SaveChanges:=True


ActiveWorkbook.SaveAs "C:\Documents and Settings\Desktop\finaloutput12.xlsx"
ActiveWorkbook.Close SaveChanges:=True
尝试仅使用保存选项。

请告诉如何保持格式。

4

1 回答 1

2

You have to use the relevant file format while saving the file.

See this table

51 = xlOpenXMLWorkbook (without macro's in 2007-2013, xlsx)
52 = xlOpenXMLWorkbookMacroEnabled (with or without macro's in 2007-2013, xlsm)
50 = xlExcel12 (Excel Binary Workbook in 2007-2013 with or without macro's, xlsb)
56 = xlExcel8 (97-2003 format in Excel 2007-2013, xls)

So your code will be written as

ActiveWorkbook.SaveAs _
"C:\Documents and Settings\Desktop\finaloutput12.xlsx", fileformat:=51

For csv, the file format is 6 so try this

ActiveWorkbook.SaveAs _
"C:\Documents and Settings\Desktop\finaloutput11.csv", fileformat:=6
于 2013-09-13T10:19:23.583 回答