Wednesday, November 18, 2009

Formatting output from CrmDiagTool4

I'm sure you know about the utility that will interrogate a CRM server and export CRM configuration details such as server details, Registry keys, CRM website details, TCP/IP, Active Directory settings, etc. The utility goes by the name "CrmDiagTool4".

To make the output of the utility more readable, I put together this short VBA script that you can run in Word 2003 or 2007.

First, run CrmDiagTool4.exe and export the system report. Then copy and paste the resulting report text into Word. You'll probably want to set the page orientation to Landscape, the margins to .25-inch, and the font for all text to Courier New 8pt.

Next, paste this script into the VBA editor and run it. It simply changes the formatting of the major report sections (lines beginning and ending with several dashes) to the Heading 1 format.


Sub FixDiagToolOutput()
   Dim headingText As String
   Dim range As range
   For Each para In ActiveDocument.Paragraphs
      If Mid(para.range.Text, 1, 10) = "----------" Then
         headingText = Replace(para.range.Text, "-", "")
         Set range = para.range
         range.Text = headingText
         range.Style = ActiveDocument.Styles("Heading 1")
      End If
   Next para
   MsgBox "Done"
End Sub


Cheers,

-Tim

No comments:

Post a Comment