PublishObjects.Add 方法 (Excel)PublishObjects.Add method (Excel)

创建一个对象,代表保存为网页的文档中的项目。Creates an object that represents an item in a document saved to a Web page. 自动的更改进行到 Microsoft Excel 中的文档时,此类对象加快到网页的后续更新。Such objects facilitate subsequent updates to the Web page while automated changes are being made to the document in Microsoft Excel. 返回一个PublishObject对象。Returns a PublishObject object.

语法Syntax

expressionexpression. Add( _SourceType_ , _Filename_ , _Sheet_ , _Source_ , _HtmlType_ , _DivID_ , _Title_ )

_表达式_一个代表PublishObjects对象的变量。expression A variable that represents a PublishObjects object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
SourceTypeSourceType 必需Required xlSourceTypexlSourceType 源的类型。The source type.
FilenameFilename 可选Optional VariantVariant StringString. (在 intranet 或 Web) 的 URL 或路径 (本地或网络) 到已保存的源对象。The URL (on the intranet or the Web) or path (local or network) to which the source object was saved.
SheetSheet 可选Optional VariantVariant 保存为网页的工作表名称。The name of the worksheet that was saved as a Web page.
SourceSource 可选Optional VariantVariant 用于标识其_SourceType_参数具有以下常量之一的项目的唯一名称: xlSourceAutoFilterxlSourceChartxlSourcePivotTablexlSourcePrintAreaxlSourceQuery,或xlSourceRangeA unique name used to identify items that have one of the following constants as their SourceType argument: xlSourceAutoFilter , xlSourceChart , xlSourcePivotTable , xlSourcePrintArea , xlSourceQuery , or xlSourceRange. 如果_SourceType_ , xlSourceRange 指定的区域,可以对已定义的名称。If SourceType is xlSourceRange , Source specifies a range, which can be a defined name. 如果_SourceType_ , xlSourceChartxlSourcePivotTablexlSourceQuery _源_指定的图表、 数据透视表或查询表的名称。If SourceType is xlSourceChart , xlSourcePivotTable , or xlSourceQuery , Source specifies the name of a chart, PivotTable report, or query table.
HtmlTypeHtmlType 可选Optional VariantVariant 指定作为一个交互式 Microsoft Office Web 组件或静态文本和图像是否保存项目。Specifies whether the item is saved as an interactive Microsoft Office Web component or as static text and images. 可以是**xlHTMLType** 常量之一: xlHtmlCalcxlHtmlChartxlHtmlListxlHtmlStaticCan be one of the xlHTMLType constants: xlHtmlCalc , xlHtmlChart , xlHtmlList , or xlHtmlStatic.
DivIDDivID 可选Optional VariantVariant 在 HTML DIV 标记中使用的唯一标识符,它用于标识网页上的项。The unique identifier used in the HTML DIV tag to identify the item on the Web page.
TitleTitle 可选Optional VariantVariant 网页的标题。The title of the Web page.

返回值Return value

一个代表新项目的**PublishObject** 对象。A PublishObject object that represents the new item.

示例Example

本示例将保存到网页称为活动工作簿中第一季度工作表上的 D5:D9 区域Stockreport.htmThis example saves the range D5:D9 on the First Quarter worksheet in the active workbook to a Web page called Stockreport.htm.

With ActiveWorkbook.PublishObjects.Add(SourceType:=xlSourceRange, _ 
    Filename:="\\Server\Stockreport.htm", Sheet:="First Quarter", Source:="$G$3:$H$6", _ 
    HtmlType:=xlHtmlStatic, DivID:="Book1_4170") 
        .Publish (True) 
        .AutoRepublish = False 
End With

另请参阅See also

PublishObjects 对象PublishObjects Object