title: Windows Script Host - JScript and VBScript with COM Object
body: <p>Stuggling here...</p>
  
  <blockquote>
    <p>VBScript</p>
  </blockquote>
  
  <p>I have a DLL loaded, and can create an Object;</p>
  
  <pre><code>Set objServer = CreateObject("Matrikon.OPC.Automation.1")
  </code></pre>
  
  <p>I can then create a new Object, based on a Property of the objServer (I think I am saying that right?)</p>
  
  <pre><code>Set objGroups = objServer.OPCGroups
  Set objGroup = objGroups.Add("Group001")
  </code></pre>
  
  <p>The manual shows <code>OPCGroups</code> is a <code>Property</code> of <code>OPCServer</code>. Once I have called this Property, I am left with a new Object of type OPCGroups, that I can then call its Properties and Methods.</p>
  
  <pre><code>Syntax  OPCGroups As OPCGroups
  </code></pre>
  
  <p>This works fine. I then continue, and get stuck when calling this function;</p>
  
  <pre><code>Syntax  AddItems (Count As Long, ItemIDs() As String, ClientHandles() As Long, ByRef  ServerHandles() As Long, ByRef Errors() As Long, Optional RequestedDataTypes As Variant, Optional AccessPaths As Variant)
  </code></pre>
  
  <p>It wants an Array of Strings. However, in VBScript, I always end up with an Array of Variants (VarType = 8204). When I try and pass my array, I get a Type Mismatch error. I can't find a way of strongly typing it to an Array of Strings; I'm not even sure it's possible.</p>
  
  <p>Over to JScript</p>
  
  <blockquote>
    <p>JScript</p>
  </blockquote>
  
  <p>I perform the same first steps as above, but when I create the <code>OPCGroups</code> object;</p>
  
  <pre><code>var objGroups = objServer.OPCGroups;
  </code></pre>
  
  <p>Something hasn't worked. It hasn't actually created an <code>OPCGroups</code> object with all its associated Properties/Methods. When I try and call a Method</p>
  
  <pre><code>var objGroup = objGroups.Add();
  </code></pre>
  
  <p>It says the 'Object doesn't support this property or method'. It's as though it just created a generic/blank Object; not one typed as an <code>OPCGroups</code> object.</p>
  
  <p>So. Can I workaround <em>either</em> of these issues? </p>