Attribute VB_Name = "modMain" Option Explicit Private Type tpeStyle selector As String properties As String End Type Sub Main() Dim cssFile As String Dim xmlFile Dim cssString As String Dim cssmlString cssFile = Command$ If Not cssFile = "" Then xmlFile = LCase$(Replace$(cssFile, ".css", ".xml", , , vbTextCompare)) setFileText xmlFile, css2cssml(getFileText(cssFile)) MsgBox "Saved to """ & xmlFile & """" End If End Sub Private Function css2cssml(ByVal css As String) As String Const seperator = "|" Dim cssml As String Dim docArr() As String Dim style() As tpeStyle Dim i As Integer css = clearCssFormatting(css) css = convertCssFormatting(css, seperator) docArr = Split(css, seperator) ReDim style(0 To UBound(docArr) \ 2 - 1) For i = LBound(docArr) To UBound(docArr) - 2 Step 2 style(i \ 2).selector = docArr(i) style(i \ 2).properties = docArr(i + 1) Next cssml = cssml & "" & vbNewLine cssml = cssml & "" & vbNewLine cssml = cssml & "" & vbNewLine cssml = cssml & "" & vbNewLine & vbNewLine For i = LBound(style) To UBound(style) cssml = cssml & "" & vbNewLine cssml = cssml & vbNewLine Next cssml = cssml & "" css2cssml = cssml End Function Private Function getSelectors(ByVal selectors As String) As String Dim selector() As String Dim i As Integer Dim cssml As String selector = Split(selectors, ",") For i = LBound(selector) To UBound(selector) cssml = cssml & " " & Trim$(selector(i)) & "" & vbNewLine Next getSelectors = cssml End Function Private Function getProperties(ByVal properties As String) As String Dim propertyValue() As String Dim propert() As String Dim i As Integer Dim cssml As String propertyValue = Split(properties, ";") For i = LBound(propertyValue) To UBound(propertyValue) propert = Split(propertyValue(i), ":") cssml = cssml & " " cssml = cssml & Trim$(propert(1)) & "" & vbNewLine Next getProperties = cssml End Function Private Function clearCssFormatting(ByVal css As String) As String css = clearCssComments(css) css = Replace$(css, vbNewLine, "") css = repeatedReplace(css, vbNewLine, "; ") css = Replace(css, ";}", "}") clearCssFormatting = css End Function Private Function clearCssComments(ByVal css As String) As String Const commStart = "/*" Const commEnd = "*/" Dim newCss As String Dim commStartI As Integer Dim commEndI As Integer Dim comment As String Dim foundComment As Boolean Dim oldString As String newCss = css Do foundComment = False oldString = newCss commStartI = InStr(newCss, commStart) If commStartI >= 1 Then commEndI = InStr(commStartI, newCss, commEnd) comment = Mid$(newCss, commStartI, commEndI - commStartI + Len(commEnd)) newCss = Replace$(newCss, comment, "") foundComment = True End If Loop Until Not foundComment clearCssComments = newCss End Function Private Function convertCssFormatting(ByVal css As String, ByVal seperator As String) As String Const scopeStart = "{" Const scopeEnd = "}" css = Replace$(css, scopeStart, seperator) css = Replace$(css, scopeEnd, seperator) convertCssFormatting = css End Function