PublishObject.Publish method (Excel)

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

Syntax

expression.Publish (Create)

expression A variable that represents a PublishObject object.

Parameters

Name Required/Optional Data type Description
Create Optional Variant If the HTML file exists, setting this argument to True replaces the file, and setting this argument to False inserts the item or items at the end of the file. If the file does not exist, the file is created regardless of the value of the Create argument.

Remarks

The FileName property returns or sets the location and name of the HTML file.

Example

This example saves the range D5:D9 on the First Quarter worksheet in the active workbook to a webpage named Stockreport.htm. The spreadsheet component is used to make the webpage interactive.

With ActiveWorkbook.PublishObjects.Add(xlSourceRange, _ 
 "\\Server1\sharedfolder\Stockreport.htm", "First Quarter", _ 
 "$D$5:$D$9", xlHtmlStatic, "Book2_25082", "") 
 .Publish (True) 
 .AutoRepublish = True 
End With

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.