Post by d***@hotmail.co.ukHello all.
I have a series of Outlook macros
Darren,
Writing VBA in VBS is fairly simple but there are translation issues. Attached are Michael Harris' instructions
on translating.
Once you have the basic translation done, and you still have problems, then post a specfic translation issue. I'm sure
someone in the newgroup could answer it.
Most of your macro questions can be answered in a search of google groups.
Bob
-------------------------------------------------------------
Here is Michael Harris' instructions on translating VBA to VBS.
From: Michael Harris \(MVP\) - view profile
Date: Fri, Sep 7 2001 2:19 pm
Email: "Michael Harris \(MVP\)" <***@mvps.org>
Groups: microsoft.public.scripting.vbscript
.......
Here's a general "vba to vbscript" translation guide:
Documentation for Office object models is supplied with every copy of Office. Start the Office
application you're interested in. On the menu bar, select Help/Contents and Index. In the contents,
select Microsoft Visual Basic Reference/Visual Basic Reference. This will bring up the VBA help
file.
When you read the help on the various objects, properties, methods, etc. you have to keep in mind
that it's for VBA, not VBScript. VBA is hosted "from the inside" by the specific application. As the
host, it automatically provides things to the VBA code that aren't automatic when you automate an
application's object model "from the outside" using VBScript hosted by WSH.
The key items to remember:
--- No objects are automatically exposed to VBScript. You generally use an explicit CreateObject to
get an instance of an object to use as the "root", usually the ".Application" object.
---In VBA that Application object and it's immediate interface members (properties/methods) are
automatically exposed. In VBScript you refer to the Application object and it's properties/methods
through the object variable reference returned by the CreateObject.
---Named constants specific to the application aren't exposed. You can either look them up and code
them locally in the VBScript code as Const variables, or you can use the .wsf file format and a
element to automatically expose them.
---VBA supports named argument syntax (e.g., ArgName:="argvalue") in method calls. In WSH hosted
VBScript, you have to code all arguments as positional arguments since named argument syntax is not
supported.
Once you understand the "VBA from the inside" vs "VBScript from the outside" issues and the
fundamental differences between VBA and VBScript as separate but similar languages, you should be
able to mentally "port" VBA and even full VB examples to VBScript.
--
Michael Harris
Microsoft.MVP.Scripting
--