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

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


表达式(SourceTypeFileNameSheetSourceHtmlTypeDivIDTitle)expression.Add (SourceType, FileName, Sheet, Source, HtmlType, DivID, Title)

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


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
SourceTypeSourceType 必需Required XlSourceTypeXlSourceType 源的类型。The source type.
FileNameFileName 可选Optional VariantVariant StringString. 源对象保存到的 URL (intranet 或 web 上) 或路径 (本地或网络)。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 webpage.
SourceSource 可选Optional VariantVariant 用来标识数据项的唯一名称,这些数据项的 SourceType 参数为下列常量之一:xlSourceAutoFilterxlSourceChartxlSourcePivotTablexlSourcePrintAreaxlSourceQueryxlSourceRangeA unique name used to identify items that have one of the following constants as their SourceType argument: xlSourceAutoFilter, xlSourceChart, xlSourcePivotTable, xlSourcePrintArea, xlSourceQuery, or xlSourceRange.

如果 SourceTypexlSourceRange,则 Source 指定的是一个区域,该区域可以是一个已定义的名称。If SourceType is xlSourceRange, Source specifies a range, which can be a defined name. 如果 SourceTypexlSourceChartxlSourcePivotTablexlSourceQuery,则 Source 指定的是图表、数据透视表或查询表的名称。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 webpage.
TitleTitle 可选Optional VariantVariant 网页的标题。The title of the webpage.

返回值Return value

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


本示例将活动工作簿中第一个工作表上的单元格区域 D5: D9 保存到名为 Stockreport.htm 的网页中。This example saves the range D5:D9 on the First Quarter worksheet in the active workbook to a webpage 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

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.