Format related procedures in class Application (Word VBA)

This page presents procedures from class Application related to the theme Format: DefaultSaveFormat, FontNames, GetDefaultTheme, LandscapeFontNames, PortraitFontNames, RestrictLinkedStyles, SetDefaultTheme, ShowStylePreviews, SmartArtColors, SmartArtLayouts, SmartArtQuickStyles, SubstituteFont, UsableHeight, UsableWidth and Visible

DefaultSaveFormat

Returns or sets the default format that will appear in the Save as type box in the Save As dialog box.

The string used with this property is the file converter class name. The class names for internal Word formats are listed in the following table.

Application.DefaultSaveFormat = ""

FontNames

Returns a FontNames object that includes the names of all the available fonts.

Dim strFont As String 
Dim intResponse As Integer 
 
For Each strFont In FontNames 
 intResponse = MsgBox(Prompt:=strFont, Buttons:=vbOKCancel) 
 If intResponse = vbCancel Then Exit For 
Next strFont

GetDefaultTheme

Returns a String that represents the name of the default theme plus the theme formatting options Microsoft Word uses for new documents, email messages, or Web pages.

You can also use the ThemeName property to return and set the default theme for new email messages.

Syntax : expression.GetDefaultTheme (DocumentType)

DocumentType: The type of new document for which you want to retrieve the default theme name.

MsgBox Application.GetDefaultTheme(wdWebPage)

LandscapeFontNames

Returns a FontNames object that includes the names of all the available landscape fonts.

Sub ListLandscapeFonts() 
 Dim docNew As Document 
 Dim intCount As Integer 
 
 Set docNew = Documents.Add 
 docNew.Content.InsertAfter "Landscape Fonts" & vbLf 
 
 For intCount = 1 To LandscapeFontNames.Count 
 docNew.Content.InsertAfter LandscapeFontNames(intCount) _ 
 & vbLf 
 Next 
 
 With docNew 
 .Range(Start:=.Paragraphs(2).Range.Start, End:=.Paragraphs _ 
 (docNew.Paragraphs.Count).Range.End).Select 
 End With 
 
 Selection.Sort 
End Sub

PortraitFontNames

Returns a FontNames object that includes the names of all the available portrait fonts.

For Each aFont In PortraitFontNames 
 With Selection 
 .Collapse Direction:=wdCollapseEnd 
 .InsertAfter aFont 
 .InsertParagraphAfter 
 .Collapse Direction:=wdCollapseEnd 
 End With 
Next aFont

RestrictLinkedStyles

Returns or sets a Boolean that represents whether Microsoft Word allows linked styles.

Linked styles are styles that can be applied either as character styles or as paragraph styles. This property corresponds to the Disable Linked Styles check box in the Styles dialog box.

Application.RestrictLinkedStyles = True

SetDefaultTheme

Sets a default theme for Word to use with new documents, email messages, or webpages.

Setting a default theme will not apply that theme to the blank document automatically created when you start Word. Any new documents you create after that will have the default theme. You can also use the ThemeName property to return and set the default theme for new email messages.

Syntax : expression.SetDefaultTheme (Name, DocumentType)

Application.SetDefaultTheme "blueprnt", wdEmailMessage

Arguments

The following arguments are required:

Name (String) - The name of the theme you want to assign as the default theme plus any theme formatting options you want to apply. The format of this string is "themennn" where theme and nnn are defined in the Themes table.

DocumentType (WdDocumentMedium) - The type of new document to which you are assigning a default theme.

Possible Values are wdDocument - Document, wdEmailMessage - Email message, wdWebPage - Web page.

ShowStylePreviews

Returns or sets a Boolean that represents whether Microsoft Word shows a preview of the formatting for styles in the Styles dialog box.

This property corresponds to the Show Preview check box in the Styles dialog box.

Application.ShowStylePreviews = True

SmartArtColors

Returns a SmartArtColors object that represents the set of color styles that are currently loaded in the application.

The set of colors represented by the SmartArtColors property correspond to the available color styles on the Change Colors button on the Design tab on the SmartArt Tools contextual tab in Word.

Dim myShape As Shape 
Dim mySmartArt As SmartArt 
 
Set myShape = ActiveDocument.Shapes.AddSmartArt(Application.SmartArtLayouts(1), 50, 50, 200, 200) 
Set mySmartArt = myShape.SmartArt 
 
mySmartArt.Color = Application.SmartArtColors(2) 

SmartArtLayouts

Returns a SmartArtLayouts object that represents the set of SmartArt layouts that are currently loaded in the application.

The set of layouts represented by the SmartArtLayouts property correspond to the available layouts in the Layouts group on the Design tab on the SmartArt Tools contextual tab in Word.

Dim myShape As Shape 
Dim mySmartArt As SmartArt 
 
Set myShape = ActiveDocument.Shapes.AddSmartArt(Application.SmartArtLayouts(1), 50, 50, 200, 200) 
Set mySmartArt = myShape.SmartArt 
 
mySmartArt.Layout = Application.SmartArtLayouts(15)

SmartArtQuickStyles

Returns a SmartArtQuickStyles object that represents the set of SmartArt styles that are currently loaded in the application.

The set of styles represented by the SmartArtQuickStyles property correspond to the available styles in the Styles group on the Design tab on the SmartArt Tools contextual tab in Word.

Dim myShape As Shape 
Dim mySmartArt As SmartArt 
 
Set myShape = ActiveDocument.Shapes.AddSmartArt(Application.SmartArtLayouts(1), 50, 50, 200, 200) 
Set mySmartArt = myShape.SmartArt 
 
mySmartArt.QuickStyle = Application.SmartArtQuickStyles.Item(6)

SubstituteFont

Sets font-mapping options.

You can find font-mapping options in the Font Substitution dialog box.

Syntax : expression.SubstituteFont (UnavailableFont, SubstituteFont)

Application.SubstituteFont UnavailableFont:= "CustomFont1", _ 
 SubstituteFont:= "Courier"

Arguments

The following arguments are required:

UnavailableFont (String) - The name of a font not available on your computer that you want to map to a different font for display and printing.

SubstituteFont (String) - The name of a font available on your computer that you want to substitute for the unavailable font.

UsableHeight

Returns the maximum height (in points) to which you can set the height of a Microsoft Word document window.

With ActiveDocument.ActiveWindow 
 .WindowState = wdWindowStateNormal 
 .Top = 5 
 .Left = 5 
 .Height = (Application.UsableHeight*0.5) 
 .Width = (Application.UsableWidth*0.5) 
End With

UsableWidth

Returns the maximum width (in points) to which you can set the width of a Microsoft Word document window.

With ActiveDocument.ActiveWindow 
 .WindowState = wdWindowStateNormal 
 .Top = 5 
 .Left = 5 
 .Height = (Application.UsableHeight*0.5) 
 .Width = (Application.UsableWidth*0.5) 
End With

Visible

True if the specified object is visible.

Application.Visible = False