ApplyTheme Method Example

This example contains a function, ApplyThemeToFilesInFolder, and a procedure that you can modify to apply any of the available themes. This example applies the "Artsy" theme to all files in a specified folder.

Note   To run this example, copy the following code into a module in the Visual Basic Editor and run the ChangeToArtsy procedure.

Function ApplyThemeToFilesInFolder(myThemeName As String, _
    myFolderObject As WebFolder) As Boolean
Dim myFile As WebFile
Dim myTheme As Theme

On Error GoTo ERR

For Each myFile In myFolderObject.Files
Call myFile.ApplyTheme(myThemeName, fpThemePropertiesAll)
Next myFile

ApplyThemeToFilesInFolder = True
Exit Function

ERR:
MsgBox "An error occured: " & ERR.Description, vbCritical, "Error!"
ApplyThemeToFilesInFolder = False
Exit Function

End Function

Private Sub ChangeToArtsy()
ApplyThemeToFilesInFolder "artsy", ActiveWeb.RootFolder
End Sub