13,825
社区成员
发帖
与我相关
我的任务
分享
Variant Excel;
Variant ExcelBook;
Variant ExcelSheet;
Excel = Variant::CreateObject( "Excel.Application" );
Excel.OlePropertySet( "Visible", false );
ExcelBook = Excel.OlePropertyGet( "workbooks" );
ExcelSheet = ExcelBook.OleFunction( "add" );
ExcelBook = Excel.OlePropertyGet( "ActiveWorkBook" );
ExcelSheet = ExcelBook.OlePropertyGet( "ActiveSheet" );
String strPrinterName = "Adobe PDF 在 Ne03:";
Excel.OlePropertyGet( "Application" ).OlePropertySet( "ActivePrinter", WideString( strPrinterName ) );
ExcelSheet.OleFunction( "PrintOut" );
我这样做就是对的。我把
ExcelSheet.OleFunction( "PrintOut" );
改成
ExcelSheet.OleFunction( "PrintOut",
EmptyParam, //From
EmptyParam, // To
1, // Copies:=1,
EmptyParam, // Preview
WideString( strPrinterName ), // ActivePrinter:= "Adobe PDF 在 Ne03:",
EmptyParam, // PrintToFile
true, // Collate:=True
EmptyParam // PrToFileName
);
实现的是打印预览功能……
后来我查资料,预览可以这样写
ExcelSheet.OleFunction( "PrintPreview", true );
太多样化了,妖哥,这些函数的定义在哪能查到啊,我也想学宏代码转换成C++#include <olectrls.hpp>
String strPrinterName = "Adobe PDF 在 Ne03:";
vExcelApp.OlePropertyGet("Application").OlePropertySet("ActivePrinter", WideString(strPrinterName));
vExcelApp.OlePropertyGet("Application").OlePropertyGet("SelectedSheets").OleFunction("PrintOut",
EmptyParam, //From
EmptyParam, // To
1, // Copies:=1,
EmptyParam, // Preview
WideString(strPrinterName), // ActivePrinter:= "Adobe PDF 在 Ne03:",
EmptyParam, // PrintToFile
true, // Collate:=True
EmptyParam // PrToFileName
);