Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search PC for Windows updates and output to Excel 1

Status
Not open for further replies.

rmiley

MIS
Apr 11, 2003
66
0
0
US
Hello all,

I'm not a programmer and I do not know VB at all. I found the following script on Windows Script Center and have found it very useful. It searches a computer for all Windows hotfixes and creates a Word document with the results.

I'd like to change the script if possible and have it create an Excel spreadsheet with the data. Can anyone help me or point me in what direction to go.

I'm guessing I need to change Set objWord = CreateObject("Word.Application") to Set objExcel = objExcel.Workbooks.Add()
set objSel = objExcel.Selection

But that doesn't seem to work. Anyone ever attempted this?

strComputer = "computername"
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colQuickFixes = objWMIService.ExecQuery("Select * from Win32_QuickFixEngineering")

'Create Word Object
Set objWord = CreateObject("Word.Application")
objWord.Caption = strComputer
objWord.Visible = True

' Create new Document
Set objDoc = objWord.Documents.Add()
set objSel = objWord.Selection

objSel.TypeText "Machine Name: " & strComputer
objSel.TypeParagraph()

For Each objQuickFix in colQuickFixes
If objQuickFix.Description <> "" Then
objSel.TypeText "Description: " & objQuickFix.Description
objSel.TypeParagraph()
objSel.TypeText "Hot Fix ID: " & objQuickFix.HotFixID
objSel.TypeParagraph()
objSel.TypeText "Installation Date: " & objQuickFix.InstallDate
objSel.TypeParagraph()
objSel.TypeText "Installed By: " & objQuickFix.InstalledBy
objSel.TypeParagraph()
End If

Next
 
Here's one I've just knocked up for you.... it's not the greatest in terms of looks but does the job..

Set objExcel = CreateObject("Excel.Application")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set ObjWorkbooks = objExcel.Workbooks.Add()
objExcel.Sheets("Sheet1").Select()
objExcel.Sheets("Sheet1").Name = "Patches Installed"
objExcel.Visible = True

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colQuickFixes = objWMIService.ExecQuery("Select * from Win32_QuickFixEngineering")


objExcel.Cells(1, 1).Value = "Computer Name: "
objExcel.Cells(1, 2).Value = "Description: "
objExcel.Cells(1, 3).Value = "Hot Fix ID: "
objExcel.Cells(1, 4).Value = "Installation Date: "
objExcel.Cells(1, 5).Value = "Installed By: "
objExcel.Cells(2, 1).Value = WshNetwork.ComputerName
Introw = 3

For Each objQuickFix in colQuickFixes
If objQuickFix.Description <> "" Then
objExcel.Cells(intRow, 2).Value = objQuickFix.Description
objExcel.Cells(intRow, 3).Value = objQuickFix.HotFixID
objExcel.Cells(intRow, 4).Value = objQuickFix.InstallDate
objExcel.Cells(intRow, 5).Value = objQuickFix.InstalledBy
IntRow = Introw + 1
End If
Next

regards
Alex

Keyboard Not Detected.....
Press F1 to Continue.
:}
 
Thank you so much Woolsdog...it's perfect for my needs. I appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top