Sunday, October 08, 2006

Insert Code from Live Writer Gallery

 

Below is a sample of a code paste into the "Insert Code" module from Omar Shahine.  As you can see it dies a nice jobe of formatting VBS code. 

 Two issues here:

1.  Code is not contained in a wrappable DIV the same as the Steve Dunn attempt.

2. Inserted HTML does not limit itself.  All future formatting is set to the last style set either before the insert or after.

While this is trivial and cosmetic it would be best if it were fixed.  I also found that running into the top of the block and accideentally deletin the opening tag will remove all formatting.

The code cannot be limited via scroll bars which is needed to limit the display area of the code in the blog entry.

Again - it would be nice to have a link that would paste the raw code to the clipboard so it sould be copied.

This code formatter cannot be easily changed by editing the HTML and adding a DIV wrapper due ti the use of PRE etc.  It took a painful amount of time to force the formatted code into the hand coded DIV.  Steve Dunn's formatter is already in a DIV and only requires the insertion of a style or adding a class tag.  This formatter can't display it's style when inside the DIV although it does show the formatiing when in Live Writer.

Both formatters are a good start.  A couple of fixes and both would be excellent additions to Live Writer.

Suggestion: Use external style sheet global to weblog. 

'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1
'
' NAME: 
'
' AUTHOR: James Vierra , Designed Systems & Services
' DATE  : 5/18/2005
'
' COMMENT: 
'
'==========================================================================

on Error Resume Next

Dim strComputer, strInput
Dim sProgram, sProgram2, sProgram3
Dim objFS, objXL, objTS
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

intRow = 3
Set objXL = WScript.CreateObject("Excel.Application")
Set objShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

sProgram = UCASE("Adobe")
sProgram2 = UCASE("Reader")
sProgram3 = UCASE("Update")

Call CollectInput()
Call BuildSpreadSheet()

Set objTS = objFS.OpenTextFile(strInput)

Do Until objTS.AtEndOfStream
  strComputer = objTS.ReadLine

'strComputer = Array("OMEGA")
For Each strComputer In objTS  
WScript.echo strComputer
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32Reg_AddRemovePrograms", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
sString = UCase(objItem.DisplayName)
sFound = InStr(sString, sProgram)

If sFound > 0 Then
sFound2 = InStr(sString, sProgram2)
sFound3 = InStr(sString, sProgram3)
If sFound2 = 0 and sFound3 = 0 Then

objXL.Cells(intRow, 1) = UCase (strComputer)
    objXL.Cells(intRow, 2) = objItem.DisplayName
    objXL.Cells(intRow, 3) = objItem.Version
    intRow = intRow + 1
     End If
   End if
  Next
 Next
Loop 

Sub CollectInput()
    Dim intDoIt

Welcome_MsgBox_Message_Text = "This script will collect Adobe Acrobat Versions (*NOT READER*) Installed on Computers."
Welcome_MsgBox_Title_Text = "Collecting Adobe Acrobat Versions"

    intDoIt =  MsgBox(Welcome_MsgBox_Message_Text, _
                      vbOKCancel + vbInformation,    _
                      Welcome_MsgBox_Title_Text )
    If intDoIt = vbCancel Then
        WScript.Quit
      End If
    
    strInput = InputBox ("Enter the TextFile for input? ")

If strInput = "" Then
   WScript.Echo "No FileName provided, The Script will Terminate"
   WScript.Quit
    End If
End Sub

Sub BuildSpreadSheet()

    objXL.Visible = True
    objXL.WorkBooks.Add()
    objXL.Sheets("Sheet1").Select()
    objXL.Sheets("Sheet1").Name = "Adobe Acrobat Inventory"
    objXL.Sheets("Sheet2").Select()
    objXL.ActiveWindow.SelectedSheets.Delete
    objXL.Sheets("Sheet3").Select()
    objXL.ActiveWindow.SelectedSheets.Delete
    objXL.Caption = "Collecting Adobe Acrobat Inventory"
    
    objXL.Rows(1).RowHeight = 30

    objXL.Columns(1).ColumnWidth = 30
    objXL.Columns(2).ColumnWidth = 30
    objXL.Columns(3).ColumnWidth = 30

    objXL.Range("A1:C1").Select
    objXL.Selection.Font.Bold = True
    objXL.Selection.Interior.ColorIndex = 11
    objXL.Selection.Interior.Pattern = 1 'xlSolid
    objXL.Selection.Font.ColorIndex = 2
    objXL.Selection.WrapText = True
    objXL.Selection.HorizontalAlignment = 3 'xlCenter
        
    objXL.Cells(1, 1).Value = "Computer"
    objXL.Cells(1, 2).Value = "Program Name"
    objXL.Cells(1, 3).Value = "Program Version"
    
End Sub





 

No comments:

Post a Comment