e800
,国内最具活力的
IT
门户网站。
http://www.e800.com.cn
【
e800
编译】此示例演示如何使用
ExportAsFixedFormat
方法在
Microsoft Excel 2010
工
作表中将数据以
或
XPS
格式导出。
此代码段是
Office
2010
的
101
项
VBA
代码示例中的一部分。与其它示例一样,这些将
可以直接写入您的代码中。
每块示例代码包含约
5
至
50
行的代码,分别演示了一个独特的功能或功能集,在
VBA
或
VB
以及
C
#中
(在
Visual Studio 2010
中创建)
。
每个示例之中都会包含代码以及相应注释,
这样您就可以直接运行获取预期的结果,
或者是根据代码注释提示来调整环境,
运行示例代
码。
Microsoft
Office
2010
提供了你所需要的工具来创建功能强大的应用程序。
Microsoft
Visual
Basic
Application
(
VBA
)代码示例可以帮助你创建自己的应用程序,以执行特定功能
或者以此为出发点实现更为复杂的功能。
实例代码
在
Excel
2010
中新建一工作簿,并将代码复制到
Sheet1
类模块。将光标置于
TestExportAsFixedFormat
内,按
F8
单步执行代码。
Sub
TestExportAsFixedFormat()
' For information on the final parameter, see this page:
' http://msdn.microsoft.com/en-us/library/aa338206.aspx
Dim
rng
As
Range
Set
rng=Range(
"A1:E10"
)
SetupRangeDatarng
Dim
fileName
As
String
' Change this file name to meet your own needs:
fileName=
"C:\Temp\Export.pdf"
' Many of these properties are optional, and are included
' here only to demonstrate how you might use them. The
' Type parameter can be one of xlTypePDF and xlTypeXLS;
' the Quality parameter can be one of xlQualityStandard and
' xlQualityMinimum. Setting the OpenAfterPublish property
' to True will fail if you don't have a default viewer