VBS Script To Export SMS Web Reports To Microsoft Word

 

This Vbs script will take an SMS site server name and site code from an input box and then enumerate all of the SMS Web Reports on that server. It will then add them to a Microsoft Word document that you can save for future reference. You can also save the document as a webpage or as an XML document if you are using Microsoft Word 2003.

 

Note: The script uses the SMS_Report class and exposes its SQLQuery lazy property by using the GET instance for the object property and links the Report ID for the appropriate reports. For more information on lazy properties see the link at the end of this post.

 

Vbs Script:

 

strComputer = InputBox ("Enter Site Server Name")

strSiteCode = InputBox("Enter Site Code")

 

Set objWord = CreateObject("Word.Application")

objWord.Visible = True

 

Set objDoc = objWord.Documents.Add()

Set objSelection = objWord.Selection

 

objSelection.Font.Bold = True

objSelection.TypeText "SMS Web Reports For " & UCase(strComputer)

objSelection.Font.Bold = False

objSelection.TypeParagraph()

objSelection.TypeText "Report Created: " & Date

objSelection.TypeParagraph()

objSelection.TypeParagraph()

 

Set objWMIService = GetObject("winmgmts://" & strComputer & "\root\sms\site_" & strSiteCode)

Set colItems = objWMIService.ExecQuery("Select * from SMS_Report")

 

For Each objItem in colItems

ReportQuery(objItem.ReportID)

Next

 

Function ReportQuery(ReportID)

Set lazyproperties = objWMIService.Get("SMS_Report.ReportID=" & ReportID)  

objSelection.Font.Bold = True

objSelection.TypeText lazyproperties.Name

objSelection.Font.Bold = False

objSelection.TypeParagraph()

objSelection.TypeParagraph()

 

objSelection.TypeText lazyproperties.SQLQuery

objSelection.TypeParagraph()

objSelection.TypeParagraph()

End Function

 

MsgBox "Done"

 

Those Lazy SMS Properties:

http://myitforum.com/cs2/blogs/dhite/archive/2006/11/17/those-lazy-sms-properties.aspx

 

Published Tuesday, November 28, 2006 12:57 PM by dhite
Filed under:

Comments

# New Asset Management Reports For SMS 2003 Service Pack 3

When you upgrade your SMS 2003 site to Service Pack (SP) 3 the following new additional asset management

Sunday, May 06, 2007 7:39 AM by Don Hite

# VBS Script To Export SMS Queries To Microsoft Word

This Vbs script will take an SMS site server name and site code from an input box and then enumerate

Sunday, February 24, 2008 4:00 PM by Don Hite

# re: VBS Script To Export SMS Web Reports To Microsoft Word

How about one to export all SMS Collection queries?

f4jock@gmail.com

Thanks

Sunday, February 24, 2008 7:49 PM by bremeski

# re: VBS Script To Export SMS Web Reports To Microsoft Word

VBS Script To Export SMS Queries To Microsoft Word

myitforum.com/.../vbs-script-to-export-sms-queries-to-microsoft-word.aspx

Don

Monday, February 25, 2008 10:24 AM by dhite

# re: VBS Script To Export SMS Web Reports To Microsoft Word

Thanks, but the queries do not include the collections (collection queries/code) that we need to backup. We rarely use the queries feature of SMS, but of course the queries within our collections are extremely important! Isn't there a table holding these collection queries somewhere? It would be great to see a Vb script that could extract these.

Thanks.

Monday, February 25, 2008 12:00 PM by bremeski