用OLE将EXCEL另存为其他格式

wwei07 2005-03-20 08:45:03
EXCEL中想将.xls另存为.htm,或.htm另存为.xls,录制的宏如下:

Sub Macro1()
'
' Macro1 Macro
' 宏由 MC SYSTEM 录制,时间: 2005-3-15
'

'
ActiveWorkbook.SaveAs Filename:= _
"F:\cc.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.SaveAs Filename:= _
"F:\cc.htm", FileFormat:=xlHtml, _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.SaveAs Filename:= _
"F:\cc.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub
======================================================
以下代码可以“另存为”,但无法转换文件格式!
Variant vExcelApp, vWorkbook, vRange,;
vExcelApp = Variant::CreateObject("Excel.Application");
vExcelApp.OlePropertySet("Visible", false);
vExcelApp.OlePropertyGet("WorkBooks").OleProcedure("Open", "A.HTM");//A.HTM是别的.XLS转存的
vWorkbook = vExcelApp.OlePropertyGet("ActiveWorkbook");

vExcelApp.OlePropertySet("Visible",(Variant)true);
Sleep(2000);

vWorkbook.OleProcedure("SaveAs", "A.xls");//这里的A.xls还是A.HTM的文本内容
=============================================================================

我要问:用OLE的什么方法可以设置FileFormat?如同宏的:FileFormat:=xlNormal



...全文
651 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwei07 2005-03-20
  • 打赏
  • 举报
回复
好象不行
僵哥 2005-03-20
  • 打赏
  • 举报
回复
楼主可能需要的是:
vWorkbook.OleProcedure("SaveAs", "A.xls",-4143/*XlFileFormat.xlWorkbookNormal*/);//
僵哥 2005-03-20
  • 打赏
  • 举报
回复
vWorkbook.OleProcedure("SaveAs", "A.xls",43/*XlFileFormat.xlExcel9795*/);//这里的A.xls还是A.HTM的文本内容
18 XlFileFormat.xlAddIn Microsoft Office Excel 加载宏(*.xla)
6 XlFileFormat.xlCSV CSV (逗号分隔)(*.csv)
22 XlFileFormat.xlCSVMac
24 XlFileFormat.xlCSVMSDOS
23 XlFileFormat.xlCSVWindows
-4158 XlFileFormat.xlCurrentPlatformText
7 XlFileFormat.xlDBF2 DBF 2 (dBASE II) (*.dbf)
8 XlFileFormat.xlDBF3 DBF 3 (dBASE III) (*.dbf)
11 XlFileFormat.xlDBF4 DBF 4 (dBASE IV) (*.dbf)
9 XlFileFormat.xlDIF DIF (数据交换格式)(*.dif)
16 XlFileFormat.xlExcel2 Microsoft Excel 2.1 工作表(*.xls)
27 XlFileFormat.xlExcel2FarEast
29 XlFileFormat.xlExcel3 Microsoft Excel 3.0 工作表(*.xls)
33 XlFileFormat.xlExcel4 Microsoft Excel 4.0 工作表(*.xls)
35 XlFileFormat.xlExcel4Workbook Microsoft Excel 4.0 工作簿(*.xlw)
39 XlFileFormat.xlExcel5 Micorosoft Excel 5.0/95 工作薄(*.xls)
39 XlFileFormat.xlExcel7 Micorosoft Excel 5.0/95 工作薄(*.xls)
43 XlFileFormat.xlExcel9795 Microsoft Excel 97- Excel 2003 & 5.0/95 工作簿(.*.xls)
44 XlFileFormat.xlHtml 网页(*.htm;*.html)
26 XlFileFormat.xlIntlAddIn
25 XlFileFormat.xlIntlMacro
2 XlFileFormat.xlSYLK SYLK (符号链接)(*.slk)
17 XlFileFormat.xlTemplate 模板(*.xlt)
19 XlFileFormat.xlTextMac
21 XlFileFormat.xlTextMSDOS 文本文件(制表符分隔)(*.txt)
36 XlFileFormat.xlTextPrinter 带格式文本文件(空格分隔)(*.prn)
20 XlFileFormat.xlTextWindows
42 XlFileFormat.xlUnicodeText Unicode 文本(*.txt)
45 XlFileFormat.xlWebArchive 单个文件网页(*.mht;*.mhtml)
14 XlFileFormat.xlWJ2WD1 WD1 (1-2-3) (*.wd1)
40 XlFileFormat.xlWJ3
41 XlFileFormat.xlWJ3FJ3
5 XlFileFormat.xlWK1 WK1 (1-2-3) (*.wk1)
31 XlFileFormat.xlWK1ALL WK1,ALL (1-2-3) (*.wk1)
30 XlFileFormat.xlWK1FMT WK1,FMT (1-2-3) (*.wk1)
15 XlFileFormat.xlWK3 WK3 (1-2-3) (*.wk3)
32 XlFileFormat.xlWK3FM3 WK3,FM3 (1-2-3) (*.wk3)
38 XlFileFormat.xlWK4 WK4 (1-2-3) (*.wk4)
4 XlFileFormat.xlWKS WKS (Works) (*.wks)
-4143 XlFileFormat.xlWorkbookNormal Microsoft Office Excel 工作簿(*.xls)
28 XlFileFormat.xlWorks2FarEast
34 XlFileFormat.xlWQ1 WQ1 (Quattro Pro/DOS) (*.wq1)
46 XlFileFormat.xlXMLSpreadsheet XML 表格(*.xml)
wwei07 2005-03-20
  • 打赏
  • 举报
回复
行了,谢谢!!

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧