Developer Documentation archives - The VBScript Network and Systems Administrator's Cafe

The VBScript Network and Systems Administrator's Cafe:

Developer documentation

Jul 18 2008   3:46PM GMT

Useful site: Tons of free books online… did I mention free?



Posted by: Jerry Lees
Networking, routers, Documentation, Development, Developer documentation, Exchange, web sites, online books, online resources

I like free stuff. Who doesn’t? And with the price of technology books you can imagine I was amazed when I found a pretty cool site recently, Scribd, that allows you to upload electronic documents. They then add this document to the database they have and make it search-able. Plus, you can search the database for specific subjects or words.

Not only are regular people uploading books and documents, but there are publisher’s uploading books. Sometimes they are just excerpts, but sometimes they are entire books as well like:

ASP Programming for the Absolute Beginner
Beginning ASP NET 3 5 in C Sharp 2008 From Novice to Professional
MSPress Exam 70-284 Implementing and managing Exchange server 2003

There’s even a CCIE Study Guide and my personal favorite the VBScript Complete Reference !

 And Many Many more… so stroll on over there and see what you can find!

Enjoy!

Jul 3 2008   2:55AM GMT

VBScript Statements: Explanation of the Rem Statement



Posted by: Jerry Lees
VBScript, Developer documentation, VBScript Statements, vbscriptstatements, REM

The VBScript REM statement is used to place a comment in your script or function. It is typically considered essential to place comments in code, not only to document what something does for others– but for yourself 6 months down the line.

 Another short hand method of placing a comment in the code is to use the ‘ character to comment the code. Below are two examples:

 Rem This is a comment
‘ This is a comment too
x=x+1 ‘this is a comment after a line of code, the code is processed and the comment is ignored.


Apr 30 2008   2:20PM GMT

Using VBScript to create Word documents automatically with the Word.Application Object



Posted by: Jerry Lees
Documentation, VBA, VBScript, DataManagement, Developer documentation, Word.application

I recently had a project that required me to create a ton of documentation from data that was already stored in files elsewhere on the network– just not in the format that was required and readable by every day people within IT. (Basically, non-administrators) This project would have required a TON of copy and paste operations or a whole lot MORE reworking of a document, plus I was on a tight deadline. So I decided to use a little VBA (Visual Basic for Applications) knowledge I had picked up in the past to work with the Microsoft Word Application interface and do the job, with only minor reworking after the fact to really tidy up the document.

First, let me clarify. Most of my scripts I use here require nothing more than the items I mentioned in my first posting (Getting Started Writing VBScript to Administer a Windows 2000 or 2003 Network) on this blog… a VBScript editor. (Notepad will do… but you’ll likely quickly want something a bit more powerful before long.) The scripts I discuss in this series are one exception, for these scripts we discuss in the next few articles we will need to make sure you have Microsoft Word installed where ever you run the script. However, for the purposes of this type of work your workstation should work fine and will likely already have Microsoft word installed! Bonus!

The “magic” component we need to call and create an object from is called Word.Application, as you’ll see below, it’s pretty easy to create a word document from VBScript and then have auto generating documentation!

The next sections of code will show you how to do various tasks with in word. Many sections are not scripts on themselves, but in fact snippets that could be placed into the first script prior to the remark for testing. The first snippet, creates a word document and saves it to the root of your C: drive. When you run this it will run, but create a blank word document– much like if you right clicked somewhere and selected New/Microsoft Word Document. Here are some common tasks in word I use:

Create a new (empty) Word Document and save it to c:\testdoc.doc
Set objWord = CreateObject(”Word.Application”)
‘note: if you don’t want word popping up and displaying as this is built– set this next line to False

objWord.Visible = True
Set objDoc = objWord.Documents.Add()
’save the Word Document
objDoc.SaveAs(”C:\testdoc.doc”)

Setting the Font type
objSelection.Font.Name = “Arial”

Setting the Font Size
objSelection.Font.Size = “18″

Adding Text
objSelection.TypeText “Add your text here”
objSelection.TypeParagraph()

Setting the typeface to bold
objSelection.Font.Bold = True

Closing the word document (generally done after saving)
objWord.Quit

These should get you started playing with VBScript to create word documents. For more information on working with Microsoft word in VBScript look here at Microsoft’s site, while it’s not related exactly to VBScript– it should give you enough information about the interface to get started.

 Next time, I’ll share a script to document settings in Group policy with a word document through a combination of using Word.Application and Microsoft.XMLDOM.

As always, this code works perfectly. However, sometimes the formatting of the blog breaks the code if you copy and paste it into your editor. So, if you’d like to not type or troubleshoot any syntax errors due to the copy and paste problems– I’ve provided the code for download, plus example output files  from my final tests for you. You’ll find the code and other files available for download from my website’s (www.websystemsadministration.com) File Depot under the ITKE Blog Scripts category. Enjoy and happy scripting!