title: how to define a range object in VBscript
body: <p>I'm trying to convert VBA program to VbScript in order to run it from the cmd.
  I created a program in VBA that get an excel workbook and um-marged cells while keeping its content in all the newly formed un-marged cells.
  explanation:
  the balded zeros are in one merged cell and the one are in a non-merged cells</p>
  
  <p><strong><em>[[0][0]][0][0]]</strong>[1][1][1]</em></p>
  
  <p>After the function I expect the result to look like:</p>
  
  <p><em>[0][0][0][0][1][1][1]</em></p>
  
  <p>each value in one single cell</p>
  
  <p>I wrote a VBA script that doing it</p>
  
  <p>this function take one sheet and un-marge all the cells while keeping the values for all of the newly formed cells </p>
  
  <pre><code>Sub UnMergeFill(ByVal ws As Worksheet)
  
      Dim cell As Range, joinedCells As Range
  
      For Each cell In ws.UsedRange
          If cell.MergeCells Then
              Set joinedCells = cell.MergeArea
              cell.MergeCells = False
              joinedCells.Value = cell.Value
          End If
      Next
  
  End Sub
  </code></pre>
  
  <p>this  function takes the first function and applys it for all the sheets in the workbook</p>
  
  <pre><code>sub UnMergeFillAllSheets()
      Dim ws As Worksheet
      for Each ws In Worksheets
           UnMergeFill ws
      Next
  End Sub
  </code></pre>
  
  <p>when I'm converting it to VBScript its looks like:</p>
  
  <pre><code>Set objExcel = CreateObject("Excel.Application")
  objExcel.Visible = True
  Dim myworkbook, worksheetcount,cell
  Set myworkbook = objExcel.Workbooks.Open("C:\Users\sm\Documents\work\try\try.xlsx")
  worksheetcount = myworkbook.Worksheets.Count
  Msgbox ("there are:"&amp;worksheetcount&amp;" sheets")'testing
  set cell = CreateObject("Range")
  For i= 1 To worksheetcount
      set ws = objExcel.Worksheets(i)
      ws.Activate
      for each cell in ws.UsedRange
  
      **take all merge cells and un-merge them**
  
      Next
  
  Next
  </code></pre>
  
  <p>my problem is that I need to refer a range of merged cells,
  when I'm trying to create a range object I'm getting an error:</p>
  
  <blockquote>
    <p>activeX component can't create object:'Range'</p>
  </blockquote>
  
  <p>I know Range exists because I used TypeName(ws.UsedRange) and the object is range type.</p>
  
  <p>Thank you for your help</p>