Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Unpacking and repacking files in themes in FrontPage


View products that this article applies to.

Summary

This article provides sample Windows Script Host (WSH) scripts that can be used to unpack and repack files used in FrontPage themes.

↑ Back to the top


More information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

FrontPage Themes

FrontPage installs themes to the following folder by default:
C:\Program Files\Common Files\Microsoft Shared\Themes
All themes created by you are saved in the following folder:
%USERPROFILE%\Application Data\Microsoft\Themes
Individual themes are saved in a folder named after the theme. For example, the Artsy theme is saved in the Artsy folder. In each theme folder is a file with a .inf file extension and a file with a .elm file extension. The file names match the name of the folder. For example, the Artsy folder contains the Artsy.inf and the Artsy.elm files.

The .inf file contains descriptive information about the theme. The .elm file is a self-defining file list for the theme. It contains an uncompressed concatenation of all the files that compose the theme. The following list shows the basic file format of a .elm file:
  • Line 1: VVV (where VVV is the version number of the .elm file format)
  • Line 2: NNN (where NNN is the number of individual files packed in the .elm file)
  • Line 3 to Line (NNN + 2): filename,filelength
  • Line (NNN + 2) to EOF: "<==MS-Theme==>" & filedata
FrontPage 2000 integrates theme editing functionality so that you can create or modify FrontPage themes. It does not allow you to easily manipulate all of the files in the theme. The WSH code samples provided in this article either unpack all the files in a .elm file or repack the individual files back into a .elm file.

IMPORTANT NOTES
  • If you incorrectly modify a theme, the theme may become unusable and you may need to reinstall it to use it again. Therefore, if you modify a theme, save the theme under a different file name by clicking Save As in the FrontPage 2000 Themes dialog box.
  • Save the WSH code samples as Unpack_elm.vbs and Repack_elm.vbs. If you don't they will not work correctly.
  • Run the scripts listed in this article from a theme's folder; if you run them from a different folder, you may receive errors.
  • The WSH code sample for repacking the .elm file builds the .elm file from all files that are in the folder excluding the .elm file, the inf file, the Unpack_elm.vbs file, and the Repack_elm.vbs file. Because it packs all other files found in the theme's folder into the .elm file, some unused files may be stored in the .elm file.

Unpacking a .elm File

The following WSH script sample unpacks a .elm file into the individual files used in the theme.
  1. Save the following WSH code as Unpack_elm.vbs on your desktop:
    Option Explicit
    
    ' Declare all variables.
    Dim objFSO,objFolder
    Dim objInputFile
    Dim objOutputFile
    Dim strELM
    Dim lngFileCount
    Dim strFileName
    Dim strFileLength
    Dim strFileVersion
    Dim strFileArray()
    Dim X
    
    ' Create constants for the .elm version and Theme string.
    Const strELMVersion  = "4.0.2.4022"
    Const strThemeString = "<==MS-Theme==>"
    
    ' Create object for file I/O.
    Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
    
    ' Get object for current folder.
    Set objFolder = objFSO.GetFolder(".")
    
    ' Create variable for .elm file.
    strELM = LCase(objFolder.Name & ".elm")
    
    ' Open the .elm file.
    Set objInputFile = objFSO.OpenTextFile(strELM)
    
    ' Get the .elm file's version.
    strFileVersion = objInputFile.ReadLine
    
    ' Get the file count.
    lngFileCount = CLng(objInputFile.ReadLine)
    
    ' Create an array for file information.
    ReDim strFileArray(lngFileCount)
    
    ' Create array from the file name/size list in the .elm file.
    For X = 1 to lngFileCount
      strFileArray(X) = objInputFile.ReadLine
    Next
    
    ' Loop through the array of files.
    For X = 1 to lngFileCount
      ' Get the file name.
      strFileName = Left(strFileArray(X),InStrRev(strFileArray(X),",")-1)
      ' Get the file size.
      strFileLength = Mid(strFileArray(X),Len(strFileName) + 2)
      ' Create a file object for the output file.
      Set objOutputFile = objFSO.CreateTextFile(strFileName)
      ' Skip past the MS Theme text.
      objInputFile.Read Len(strThemeString)
      ' Extract the packed file data from the .elm file.
      objOutputFile.Write objInputFile.Read(strFileLength)
      ' Close the output file.
      objOutputFile.Close
    Next
    
    Set objFolder = Nothing
    Set objFSO = Nothing
    					
  2. Copy the Unpack_elm.vbs file to the folder containing a packed theme. For example, if you want to unpack the Artsy theme files, copy the Unpack_elm.vbs file to the Artsy folder:
    C:\Program Files\Common Files\Microsoft Shared\Themes\artsy
  3. Double-click the Unpack_elm.vbs script to run it.
  4. When the script is finished, the graphics and text files that make up the theme will be unpacked in the folder.

Repacking a .elm File

The following sample WSH script sample repacks the individual files used in the theme into a .elm file.
  1. Save the following WSH code as Repack_elm.vbs on your desktop:
    Option Explicit
    
    ' Declare all variables.
    Dim objFSO,objFile,objFolder
    Dim objInputFile
    Dim objOutputFile
    Dim strELM,strINF
    Dim strPACK,strUNPACK
    Dim strName,strFileNames
    Dim strFileArray,lngFileCount
    Dim X
    
    ' Create constants for the .elm version and the theme string.
    Const strELMVersion  = "4.0.2.4022"
    Const strThemeString = "<==MS-Theme==>"
    
    ' Create object for file I/O.
    Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
    ' get object for current folder
    Set objFolder = objFSO.GetFolder(".")
    
    ' Create variables for ignored file names.
    strELM    = LCase(objFolder.Name & ".elm")
    strINF    = LCase(objFolder.Name & ".inf")
    strPACK   = "repack_elm.vbs"
    strUNPACK = "unpack_elm.vbs"
    
    ' Loop through the files collection.
    For Each objFile in objFolder.Files
      ' Get a file name.
      strName = objFile.Name
      ' Is the file name an ignored file name?
      If (LCase(strName) <> strELM) And _
         (LCase(strName) <> strINF) And _
         (LCase(strName) <> strPACK) And _
         (LCase(strName) <> strUNPACK) Then
        strFileNames = strFileNames & ":" & strName
      End If
    Next
    
    ' Create an array of file names.
    strFileArray = Split(strFileNames,":")
    lngFileCount = UBound(strFileArray)
    
    If lngFileCount > 0 Then
      ' Open the .elm file.
      Set objOutputFile = objFSO.CreateTextFile(strELM,-1,0)
    
      ' Output the .elm version and file count.
      objOutputFile.Write strELMVersion & vbLf
      objOutputFile.Write lngFileCount & vbLf
    
      ' Loop through the files.
      For X = 1 To lngFileCount
        Set objFile = objFSO.GetFile(strFileArray(X))
        objOutputFile.Write objFile.Name & "," & objFile.Size & vbLf
      Next
    
      ' Loop through the files.
      For X = 1 To lngFileCount
        Set objFile = objFSO.GetFile(strFileArray(X))
        objOutputFile.Write strThemeString
        Set objInputFile = objFSO.OpenTextFile(objFile.Name,1)
        objOutputFile.Write objInputFile.Read(objFile.Size)
        objInputFile.Close
      Next
    
      objOutputFile.Close
    End If
    
    Set objFolder = Nothing
    Set objFSO = Nothing
    					
  2. Copy the Repack_elm.vbs file to the folder containing an unpacked theme. For example, if you unpacked the Artsy theme, copy the Repack_elm.vbs file to the following folder:
    C:\Program Files\Common Files\Microsoft Shared\Themes\artsy
  3. Double-click the Repack_elm.vbs script to run it.
  4. When the script is finished, the graphics and text files will be repacked in the .elm file for the theme.

↑ Back to the top


References

For more information about customizing FrontPage themes, click Microsoft FrontPage Help on the Help menu, type Customize a theme in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For more information about customizing FrontPage, see the following Microsoft web site:

↑ Back to the top


Keywords: KB295409, kbinfo

↑ Back to the top

Article Info
Article ID : 295409
Revision : 4
Created on : 1/31/2007
Published on : 1/31/2007
Exists online : False
Views : 416