Class PublishObject (Excel VBA)

The class PublishObject represents an item in a workbook that has been saved to a webpage and can be refreshed according to values specified by the properties and methods of the PublishObject object.

Member in collection


To use a PublishObject class variable it first needs to be instantiated, for example

Dim pblobj as PublishObject
Set pblobj = ActiveWorkbook.PublishObjects(Index:=1)

The following procedures can be used to set variables of type PublishObject: PublishObjects.Add and PublishObjects.Item.

For Each

Here is an example of processing the PublishObject items in a collection.

blnChartFound = False 
For Each objPO In Workbooks(1).PublishObjects 
 If objPO.SourceType = xlSourceChart Then 
 strFirstPO = objPO.Source 
 blnChartFound = True 
 Exit For 
 End If 
Next objPO


Delete - Deletes the object.

Publish - Saves an item or a collection of items in a document to a webpage.

PublishObjects.Add - Creates an object that represents an item in a document saved to a webpage. Such objects facilitate subsequent updates to the webpage while automated changes are being made to the document in Microsoft Excel. Returns a PublishObject object.

PublishObjects.Delete - Deletes the object.

PublishObjects.Publish - Saves a copy of the item or items in the spreadsheet that have been added to the PublishObjects collection to a webpage.


PublishObjects.Item (Default member) - Returns a single PublishObject object from the collection.

AutoRepublish when a workbook is saved, Microsoft Excel determines if any item in the PublishObjects collection has the AutoRepublish property set to True, and if so, republishes it. The default value is False.

DivID returns the unique identifier used for identifying an HTML

tag on a webpage. The tag is associated with an item in a document that you have saved to a webpage. An item can be an entire workbook, a worksheet, a selected print range, an AutoFilter range, a range of cells, a chart, a PivotTable report, or a query table.

Filename returns or sets the URL (on the intranet or the web) or the path (local or network) to the location where the specified source object was saved.

HtmlType returns or sets the type of HTML generated by Microsoft Excel when you save the specified item to a webpage. Can be one of the XlHtmlType constants specifying whether the item is static or interactive on the webpage. The default value is xlHtmlStatic.

Sheet returns the sheet name for the specified PublishObject object.

Source returns a value that represents the unique name that identifies items that have a SourceType property value of xlSourceRange, xlSourceChart, xlSourcePrintArea, xlSourceAutoFilter, xlSourcePivotTable, or xlSourceQuery.

SourceType returns an XlSourceType value that represents the type of item being published.

Title returns or sets the title of the webpage when the document is saved as a webpage.

PublishObjects.Count returns a Long value that represents the number of objects in the collection.