Friday, October 23, 2009

VBScript, VB, VBA Scripts and The Like: A Few Basic Facts

First two samples. A VBScript:

WScript.Echo "About to create an new SharePoint.OpenDocuments.1"

dim obj
set obj = CreateObject("SharePoint.OpenDocuments.1")

WScript.Echo "Finished"

And a VBA:
Public Sub myTest()
    Dim spObject As Object
    Dim aaa As String
    On Error Resume Next
    Set spObject = CreateObject("SharePoint.OpenDocuments.1")
    If Err.Number <> 0 Then
        aaa = "sss"
    End If   
End Sub

  • In VBScript, the try/catch/finally/end try is available.  Not in VB/VBA.
  • VBA runs in a MS Office App only, while the VBScript is more like JavaScript: can run in the browser or from the command line. Use CScript.exe to run in the latter environment.
  • How to output a line to the console in VB/VBA? Don't know.

No comments: