office档开发遇到的问题的解决方法笔记

1、用代码打开ppt档时,

                powerpoint = new PowerPoint.ApplicationClass();
                ppt = powerpoint.Presentations.Open(Filename,     //打开的档案名
                 Microsoft.Office.Core.MsoTriState.msoTrue,     //是否只读
                 Microsoft.Office.Core.MsoTriState.msoFalse,   //打开的文档是否需要一个标题,当为msoTrue时,打开文档名为系统指定的名字(简报1),当为msoFalse时文档名为文档本身的名字
                 Microsoft.Office.Core.MsoTriState.msoFalse);   //不显示窗口

 

 

参考 http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.presentations.open.aspx

 

Presentation Open(
	string FileName,
	MsoTriState ReadOnly,
	MsoTriState Untitled,
	MsoTriState WithWindow
)
Parameters
FileName
Type: System.String
The name of the file to open.
ReadOnly
Type: MsoTriState
Specifies whether the file is opened with read/write or read-only status.
Untitled
Type: MsoTriState
Specifies whether the file has a title.
WithWindow
Type: MsoTriState
Specifies whether the file is visible.
 
 

The Untitled parameter value can be one of these MsoTriState constants.

Constant

Description

msoFalse  

The default. The file name automatically becomes the title of the opened presentation.

msoTrue

Opens the file without a title. This is equivalent to creating a copy of the file.

 

 

 

 

 

2、  使用虚拟机Bullzip PDF Printer打印office档为pdf档时,调用方法分别为:

       ppt档打印 :ppt.PrintOut(-1, -1, null, 1, Microsoft.Office.Core.MsoTriState.msoTrue);

 

       xls档打印 :xls.PrintOut(From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName);

 

       doc档打印 :doc.PrintOut(ref background, ref append, ref range, ref OutputFileName, ref missing, ref missing,
                    ref missing, ref missing, ref missing, ref PageType, ref printToFile, ref collate, ref missing, ref missing,
                    ref missing, ref missing, ref missing, ref missing);

其中ppt的PrintOut第三个参数如果为文件名,则将文件打印成以其为文件名的.ps档,如果为空,则将档案送到打印机打印,即转化为pdf档。

xls和doc档的PrintOut函数,当PrintToFile为true的时候,则将文件打印成以prToFileName和OutputFileName为文件名的.ps档,当PrintToFile为false的时候,则将档案送到打印机打印,即转化为pdf档。

 

参考:http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint._presentation.printout.aspx

ppt PrintOut函数:
void PrintOut(
	int From,
	int To,
	string PrintToFile,
	int Copies,
	MsoTriState Collate
)
Parameters
From
Type: System.Int32
The number of the first page to be printed. If this argument is omitted, printing starts at the beginning of the presentation. Specifying the To and From arguments sets the contents of the PrintRanges object and sets the value of the RangeType property for the presentation.
To
Type: System.Int32
The number of the last page to be printed. If this argument is omitted, printing continues to the end of the presentation. Specifying the To and From arguments sets the contents of the PrintRanges object and sets the value of the RangeType property for the presentation.
PrintToFile
Type: System.String
The name of the file to print to. If you specify this argument, the file is printed to a file rather than sent to a printer. If this argument is omitted, the file is sent to a printer.
Copies
Type: System.Int32
The number of copies to be printed. If this argument is omitted, only one copy is printed. Specifying this argument sets the value of the NumberOfCopies property.
Collate
Type: MsoTriState
If this argument is omitted, multiple copies are collated. Specifying this argument sets the value of the Collate property.

The Collate parameter value can be one of these MsoTriState constants.

Constant

Description

msoFalse       

Prints all copies of one page before printing the first copy of the next page.

msoTrue   

Prints a complete copy of the presentation before the first page of the next copy is printed.

xls PrintOut函数   http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._worksheet.printout.aspx

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值