VB Script source

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

VB Script source

Post by Bob Hansen » Sat Oct 11, 2003 11:06 pm

After I submitted some VB code for using with Outlook on
http://www.mjtnet.com/usergroup/viewtopic.php?t=611 I received the following question in my email:
I am farley new to VBScript and Macro Scheduler. I have been reviewing a lot of code that folks have submitted, along with some online documentation in an effort to teach myself without asking for every answer. I bought a VBScript book that covered version 5.6, however I am looking for a book or online resource, that I can read up on the VBScripting that you used in your recent Outlook code for example the following statements:

Set objOutlook = CreateObject("Outlook.Application")

Set objMailItem = objOutlook.CreateItem(0)

I have seen similar Excel examples as well, however where are these things explained, i.e. the specific reserved words for Outlook, Excel ...

Is it VBA, rather than VBScript?

I work with all of the Microsoft products a lot, and want to automate many functions in them and between them, however using Macro Scheduler only (without VBScript) is slower and a bit more clunky than the kind of coding you employed here. In some cases Macro Scheduler alone is great, however often a mix of MacroSchedluer with embedded VBScript works best.
:idea: I thought I would share my reply to that question:
Thanks for your "Nice work!" heading. Let me see if I can provide a Sensible Solution for you. I use Macro Scheduler daily to integrate many other applications with the Office modules. Could not work without it! And you are correct that some tasks are best done with VB vs. Macro Scheduler. (If speed is not an issue, I usually prefer to use the equivalent Macro Scheduler functions so that I can record progress in logs, cannot easily do that in VB, just get the function results).

I have picked up most of my VB skills from developing in Access. While doing that I became familiar with Helen Feddema who is a regular contributor of Woody's Access Watch monthly newsletter (Email to join WAW: [email protected]. I highly recommend ALL of Woody's newsletters.). Helen has her own site at http://www.helenfeddema.com/ where she has provided lots of well documented and commented VBA code. From her home page, click on the button for Code Samples. Note, that she loves to write code, and this will not be an easy read. But if you take your time, she does explain all that she does. You should really review a lot of the free code on her site.

Helen is also the author of DAO Object Model, The Definitive Reference, which is excellent for explaining the Office objects. Here is a link to Amazon:
http://www.amazon.com/exec/obidos/ISBN% ... 71-3637751

I don't have standalone VB, so the "reserved word" list I have found is best located by going into the design mode in Office Modules and calling up the Object Browser. In there you will find that each Office Module has its own library of Objects, and when you select an Object, you can then see the Methods for each object. Select the Method, and then select Help, and you will get definitions, syntax, examples, and "other items to explore".

As an example, I was not familiar with most of the Outlook objects before I made my submitted script. I found some examples in Helen's code, then went to Outlook to understand what objects were available. To see the objects, Open Outlook, go to the Inbox, and start from the Main Menu. Click on Tools, Forms, Design a Form. Highlight Message, click on Open. On the Form Design window that opens, click on Form, View Code. On the next window that opens up, Script Editor, click on Script, Object Browser. (There may be an easier way, but I just walked my way through that process).

Using Helen's book will help to define Objects, Methods, etc. Much of VBA code is usable in VB script, and I don't know the exact difference. but this is a reference to MSDN site for VB Script information: http://msdn.microsoft.com/library/defau ... Script.asp.

I am going to submit my reply to the Macro Scheduler forum so that everyone can share from the questions and answers that are exchanged.
:D
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts