I'm designing a script destined to be called from Photoshop CS2. Since I'm a
VBA programmer by proficiency, I'm coding in the familiar editing environment
of Excel's VBE. When I translate the final module to VBS, how do I account
for references I set to other libraries, namely to the Microsoft Scripting
Runtime library (C:\WINDOWS\system32\scrrun.dll)?
Is there something similar to C++'s #DECLARE statement, or is there
something different to do? I suppose I could just create
FileScriptingObjects, but I prefer to work with object libraries.
Thanks,
Matthew Pfluger
All objects in VBS are late bound. As I understand it, that means you
MUST *explicitly* bind to any and all objects/classes you intend to
use. Specifically, this almost universally means SETting a variable
using the CreateObject() method and then referencing all properties
and methods to that variable. There is a GetObject() method, but this
has limited applicability. One convenient way to make the re3ference
is with the WITH/END WITH block. Then your reference to the property
just needs to prefix the item's use with a dot.
Another thing that needs to change is the use of intrinsic constants
from 'library' objects. Unless the XML script implementation WSF file
is used, where an <object> tag can gain access to these constants, any
you need will have to be explicitly defined.
Also, named and optional function/sub arguments are NOT supported.
That is the Name:= construct needs to be removed and all arguments,
blank or not need to be provided in the order they are defined in the
base argument list.
There is also no DoEvents support, so in most cases multi-threading is
not supported (unless an asynchronous Run is used to launch another
script/application).
There is no strong typing - all variables are of type Variant, so
variable declarations with AS clauses are not supported. Any such
references will need to be removed or commented out.
Userforms are not supported, event handling requires special handling
- none are intrinsically supported - and all scripts need a main body
that invokes the needed subroutines as appropriate.
I'm sure there's more, but that's what comes to mind off the top of my
head.
One final comment: Unless I plan on using a lot of Excel's
functionality, I tend to build VBS in a plain text editor - or maybe
in the Office MSE7 IDE - because it tends to keep me straight with
regard to these issues. I DO work in the Excel environment when using
the Macro Recorder will speed the application's development and then
translate to VBS to build the stand alone.
HTH,
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/