Class DefaultWebOptions (Excel VBA)

Contains global application-level attributes used by Microsoft Excel when you save a document as a webpage or open a webpage. You can return or set attributes either at the application (global) level or at the workbook level.

Properties

AllowPNG true if PNG (Portable Network Graphics) is allowed as an image format when you save documents as a webpage. False if PNG is not allowed as an output format. The default value is False.

Application.DefaultWebOptions.AllowPNG = True

AlwaysSaveInDefaultEncoding true if the default encoding is used when you save a webpage or plain text document, independent of the file's original encoding when opened. False if the original encoding of the file is used. The default value is False.

Application.DefaultWebOptions.AlwaysSaveInDefaultEncoding = True

CheckIfOfficeIsHTMLEditor true if Microsoft Excel checks to see whether an Office application is the default HTML editor when you start Excel. False if Excel does not perform this check. The default value is True.

Application.DefaultWebOptions.CheckIfOfficeIsHTMLEditor = False

DownloadComponents true if the necessary Microsoft Office Web components are downloaded when you view the saved document in a web browser, but only if the components are not already installed. False if the components are not downloaded. The default value is False.

Application.DefaultWebOptions.DownloadComponents = True 
Application.DefaultWebOptions.LocationOfComponents = _ 
 Application.Path & Application.PathSeparator & "foo"

Encoding returns or sets the document encoding (code page or character set) to be used by the web browser when you view the saved document. The default is the system code page.

If Application.DefaultWebOptions.Encoding = msoEncodingWestern Then 
    strDocEncoding = "Western" 
Else 
    strDocEncoding = "Other" 
End If

FolderSuffix returns the folder suffix that Microsoft Excel uses when you save a document as a webpage, use long file names, and choose to save supporting files in a separate folder (that is, if the UseLongFileNames and OrganizeInFolder properties are set to True).

Fonts returns the WebPageFonts collection representing the set of fonts Microsoft Excel uses when you open a webpage in Excel and there is either no font information specified on the webpage, or the current default font can't display the character set on the webpage.

With Application.DefaultWebOptions _ 
    .Fonts(msoCharacterSetEnglishWesternEuropeanOtherLatinScript) 
        .FixedWidthFont = "Courier New" 
        .FixedWidthFontSize = 14 
End With

LoadPictures true if images are loaded when you open a document in Microsoft Excel, usually when the images and document were not created in Microsoft Excel. False if the images are not loaded. The default value is True.

Application.DefaultWebOptions.LoadPictures = True

LocationOfComponents returns or sets the central URL (on the intranet or web) or path (local or network) to the location from which authorized users can download Microsoft Office Web components when viewing your saved document. The default value is the local or network installation path for Microsoft Office.

Application.DefaultWebOptions.DownloadComponents = True 
Application.DefaultWebOptions.LocationOfComponents = _ 
 Application.Path & Application.PathSeparator & "foo"

OrganizeInFolder true if all supporting files, such as background textures and graphics, are organized in a separate folder when you save the specified document as a webpage. False if supporting files are saved in the same folder as the webpage. The default value is True.

Application.DefaultWebOptions.OrganizeInFolder = False

Parent returns the parent object for the specified object. Read-only.

PixelsPerInch returns or sets the density (pixels per inch) of graphics images and table cells on a webpage. The range of settings is usually from 19 to 480, and common settings for popular screen sizes are 72, 96, and 120. The default setting is 96.

With Application.DefaultWebOptions 
 Select Case .ScreenSize 
 Case msoScreenSize800x600 
 .PixelsPerInch = 72 
 Case msoScreenSize1024x768 
 .PixelsPerInch = 96 
 Case Else 
 .PixelsPerInch = 120 
 End Select 
End With

RelyOnCSS true if cascading style sheets (CSS) are used for font formatting when you view a saved document in a web browser. Microsoft Excel creates a cascading style sheet file and saves it either to the specified folder or to the same folder as your webpage, depending on the value of the OrganizeInFolder property. False if HTML tags and cascading style sheets are used. The default value is True.

Application.DefaultWebOptions.RelyOnCSS = True

RelyOnVML true if image files are not generated from drawing objects when you save a document as a webpage. False if images are generated. The default value is False.

Workbooks(1).DefaultWebOptions.RelyOnVML = False

SaveHiddenData true if data outside of the specified range is saved when you save the document as a webpage. This data may be necessary for maintaining formulas. False if data outside of the specified range is not saved with the webpage. The default value is True.

Application.DefaultWebOptions.SaveHiddenData = False

SaveNewWebPagesAsWebArchives true if new webpages can be saved as web archives.

Sub DetermineSettings() 
 
 ' Determine settings and notify user. 
 If Application.DefaultWebOptions.SaveNewWebPagesAsWebArchives = True Then 
 MsgBox "New webpages will be saved as Web archives." 
 Else 
 MsgBox "New webpages will not be saved as Web archives." 
 End If 
 
End Sub

ScreenSize returns or sets the ideal minimum screen size (width by height, in pixels) that you should use when viewing the saved document in a web browser. Can be one of the MsoScreenSize constants. The default constant is msoScreenSize800x600.

TargetBrowser returns or sets an MsoTargetBrowser constant indicating the browser version.

Sub CheckWebOptions() 
 
    Dim wkbOne As Workbook 
 
    Set wkbOne = Application.Workbooks(1) 
 
    ' Determine if IE5 is the target browser. 
    If wkbOne.WebOptions.TargetBrowser = msoTargetBrowserIE5 Then 
        MsgBox "The target browser is IE5 or later." 
    Else 
        MsgBox "The target browser is not IE5 or later." 
    End If 
 
End Sub

UpdateLinksOnSave true if hyperlinks and paths to all supporting files are automatically updated before you save the document as a webpage, ensuring that the links are up to date at the time the document is saved. False if the links are not updated. The default value is True.

Application.DefaultWebOptions.UpdateLinksOnSave = False

UseLongFileNames true if long file names are used when you save the document as a webpage. False if long file names are not used and the DOS file name format (8.3) is used. The default value is True.

Application.DefaultWebOptions.UseLongFileNames = False