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 all of the Queries on that server. It will then add them to a Microsoft Word document that you can save for future reference.

 

VBS Script:

 

strComputer = InputBox ("Enter Site Server Name")

strSiteCode = InputBox("Enter Site Code")

 

Set objWord = CreateObject("Word.Application")

objWord.Visible = True

 

Const wdAlignParagraphCenter = 1

Const wdAlignParagraphLeft = 0 

 

Const wdColorGreen = 32768

Const wdColorBlue = 16711680

Const wdColorBlack = 0

Const wdColorGray = 15132390

 

Set objDoc = objWord.Documents.Add()

Set objSelection = objWord.Selection

 

objSelection.Font.Bold = True

objSelection.Font.Color = wdColorGreen

objSelection.ParagraphFormat.Alignment = wdAlignParagraphCenter

objSelection.TypeText "SMS Queries For " & UCase(strComputer)

objSelection.Font.Bold = False

objSelection.TypeParagraph()

objSelection.TypeText "Report Created: " & Date

objSelection.TypeParagraph()

objSelection.TypeParagraph()

objSelection.ParagraphFormat.Alignment = wdAlignParagraphLeft

 

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

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

For Each objItem in colItems

 

objSelection.ParagraphFormat.Alignment = wdAlignParagraphCenter

objSelection.Font.Color = wdColorBlue

objSelection.Font.Bold = True

objSelection.ParagraphFormat.Shading.BackgroundPatternColor = wdColorGray

objSelection.TypeText objItem.Name

objSelection.TypeParagraph()

objSelection.TypeParagraph()

 

objSelection.ParagraphFormat.Alignment = wdAlignParagraphLeft

objSelection.Font.Color = wdColorBlack

objSelection.Font.Bold = False

objSelection.TypeText objItem.Expression

objSelection.TypeParagraph()

objSelection.TypeParagraph()

Next

 

objSelection.ParagraphFormat.Alignment = wdAlignParagraphCenter

objSelection.Font.Color = wdColorGreen

objSelection.TypeText "Created by Don Hite For myITforum.Com"

objSelection.TypeParagraph()

 

Additional Information:

 

VBS Script To Export SMS Web Reports To Microsoft Word

 

http://myitforum.com/cs2/blogs/dhite/archive/2006/11/28/vbs-script-to-export-sms-web-reports-to-microsoft-word.aspx

 

 

 

Published Sunday, February 24, 2008 3:00 PM by dhite
Filed under:

Comments

# VBS Script To Export SMS Queries To Microsoft Word

Interesting: myitforum.com

Sunday, February 24, 2008 6:00 PM by Windows Vista News

# re: VBS Script To Export SMS Queries To Microsoft Word

Thanks, but these 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 3:21 PM by bremeski

# VBS Script To Export SMS Collection WQL 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, March 02, 2008 9:21 AM by Don Hite

# VBS Script To Export A Specified SMS Query To Microsoft Word

This Vbs script is based on a previous post found below that will take an SMS site server name, site

Sunday, March 09, 2008 9:28 AM by Don Hite

# VBS Script To Export SMS WQL System Resource 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, March 30, 2008 8:44 AM by Don Hite

# VBS Script To Export SMS WQL Status Message 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, April 06, 2008 8:56 AM by Don Hite

# VBS Script To Export SMS WQL User Group Resource 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, April 13, 2008 8:45 AM by Don Hite