[mso] Re: Online VB Classes

  • From: "Greg Chapman" <greg@xxxxxxxxxxxxx>
  • To: <mso@xxxxxxxxxxxxx>
  • Date: Tue, 3 Dec 2002 12:39:26 -0600

I'm suggesting that even if you're not interested in becoming a Word
maven, you can still do well with any of the courses she offers. Word
301 isn't all about VBA but it will get you started down the path. I'd
follow that up with the Autoforms class. From what I can remember of the
syllabus for Advanced Document Design, this one has little to do with
what you're after. Dian has also written some e-books that go along with
the classes (www.mousetrax.com/books.html) that can serve as companions
to the course.

The material covered is not what I'd call complex VB coding because the
majority of the complexity she's treating here is a direct result of the
Word object model. However, there's very little need in the real world
for writing complex code when you're using VB(A,Script). Learning to
deal with code complexity is a function of using the language and object
models. So either of these courses can get you going and doing some
satisfyingly cool stuff to make the learning stick. Instead of holding
you deep into the concepts of clean code, recursive processing, etc.,
she focuses on how to get the job done without losing you along the way.

...and just because I'm feeling gamey today, I've got to throw something
out in front of you to expand on Dian's VBA example she posted earlier.
I'm a geek so this one will have to do with your file system...but it's
not about the Operating System because you'll do it from within Word (So
there, Linda!)

You'll remember that Dian suggested going to the tools menu, clicking on
Macros, etc., and typing the name of a new macro followed by pasting in
her code and running it, right? Well, do all that a second time but this
time name the new macro RecursiveDir. This is one of those "Oh cool!"
things that always tickle my geek gland. All the macro will do is
connect to the file system and, starting at the folder you provide, will
give you a Word document listing all the files and folders below that
path. It will do this by operating recursively (in other words, the
subroutine calls itself over and over). You can press F5 as Dian had you
do with her example and you'll get the boring old directory listing as a
Word document...and miss the cool part.<g> So, instead of using F5 to
run the code, press F7 to step through the code one instruction at a
time (Make sure your cursor is somewhere inside the RecursiveDir macro
before you press F7 or F5).

Here's what your final code should look like (Copy and Paste will work,
too):

Sub RecursiveDir()
Dim strStartDirectory As String

strStartDirectory = InputBox(Prompt:="Enter a path (c:\windows)")

Selection.Font.Size = 7
Selection.TypeText Text:=strStartDirectory & vbCrLf
EnumerateFiles (strStartDirectory)
EnumerateFolders (strStartDirectory)
End Sub


Sub EnumerateFiles(strDir As String)
Dim objFSO, FSOFiles, objFiles

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set FSOFiles = objFSO.GetFolder(strDir)
Set objFiles = FSOFiles.Files

For Each objFile In objFiles
    Selection.Font.Size = 7
    Selection.TypeText Text:=vbTab & objFile.Name & vbCrLf
Next objFile
End Sub


Sub EnumerateFolders(strDir As String)
Dim objFSO, FSOFOlder, objFolder

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set FSOFOlder = objFSO.GetFolder(strDir)
Set objFolders = FSOFOlder.SubFolders

For Each objFolder In objFolders
    Selection.Font.Size = 7
    Selection.TypeText Text:=objFolder.Path & vbCrLf
    EnumerateFiles (objFolder)
    EnumerateFolders (objFolder)
Next
End Sub

Okay, so there are only 3 subroutines there and the one called
EnumerateFolders calls itself over and over and over, each time
supplying itself with yet another directory to examine. That's just cool
geeky stuff! Again, if this is too much to consider now, hang on to it
because it will eventually make sense and it's worth the effort. BTW, if
you do use c:\windows as the starting path when you run the program, be
prepared for this to take a few minutes to finish the job if you press
F5. The end result will be a Word document of about 200 pages, a book
unto itself.

...and I hate programming.<g>

Greg Chapman
http://www.mousetrax.com 
"Counting in binary is as easy as 01, 10, 11!
With thinking this clear, is coding really a good idea?"


> -----Original Message-----
> From: mso-bounce@xxxxxxxxxxxxx 
> [mailto:mso-bounce@xxxxxxxxxxxxx] On Behalf Of Carol Parent
> Sent: Tuesday, December 03, 2002 10:46 AM
> To: mso@xxxxxxxxxxxxx
> Subject: [mso] Re: Online VB Classes
> 
> 
> 
> 
> Word Advanced Techniques (301) Course
> Word AutoForms and Beginning VBA Course
> Word Advanced Document Design Course
> 
http://www.mousetrax.com/techclasses.html

>>>I do recommend Dian's classes on VBA and Word to get
going.<<<<<

Hello Greg,

Are you recommending the Beginning VBA course?  I noted VBA is mentioned
in descriptions for the first two classes but would like to clarify
which is 'best' for learning beginning VBA?

Thanks much.

Best regards,

Carol Parent
info@xxxxxxxxxxx
http://www.tecminn.com

I finally got it all together...
I just wish I could remember where I set it down.

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx?Subject=unsubscribe

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: