What are the specific names for these OLE controls?

Posted by Kris on Stack Overflow See other posts from Stack Overflow or by Kris
Published on 2010-05-19T07:34:54Z Indexed on 2010/05/19 7:40 UTC
Read the original article Hit count: 406

Filed under:
|
|

I have been working on making a block of code that would enable me to input values into a worksheet, as well as an MSgraph object. I have succeeded in this, but this has just presented me with a new set of problems:

  1. What are the control names for changing the visible size as well as the focus of a worksheet?
  2. What are the control names for changing/making background colours and borders?
  3. How do I create and define new worksheets and MSGraph objects inside the document?

My example code so far:

Option Explicit

Dim objWord 'Word application object
Dim objIShape 'Inline shapes object
Dim objOLE 'OLE object

Set objWord=CreateObject("Word.Application")
objWord.Application.Documents.Open("C:\birdy.doc")
objWord.Visible=True
Set objIShape = objWord.ActiveDocument.InlineShapes

Function count_filled_spaces(intOLENo, strRange)
    'Activates the the inline shape by number(intOLENo) and defines it as the OLE object
    objIShape(intOLENo).OLEFormat.Activate
    Set objOLE = objIShape(intOLENo).OLEFormat.Object

    'Detects the ClassType of the inline shape and uses a class specific counter to count which datafields have data
    Dim strClass, i, p, intSheetno
    intSheetno = 1
    strClass = objIShape(intOLENo).OLEFormat.ClassType
    i = 0
    If Left(strClass, 8) = "MSGraph." then
        For Each p In objOLE.Application.DataSheet.Range(strRange)
            If p <> "" Then
                i = i+1
            End If
        Next
    ElseIf Left(strClass, 6) = "Excel." then
        For Each p In objOLE.Worksheets(intSheetno).Range(strRange)
            If p <> "" Then
                i = i+1
            End If
        Next
        objOLE.Worksheets(intSheetno).Range("B" & i+1) = objOLE.Worksheets(intSheetno).Range("B" & i)
    End if
    count_filled_spaces = i
End Function

Dim strRange
strRange = InputBox("Lol", "do eeet", "B1:B10")
wscript.echo count_filled_spaces(2, strRange)

'objWord.Application.Documents.Save
'objWord.Application.Documents.Close
'objWord.Application.Quit
WScript.Quit(0)

© Stack Overflow or respective owner

Related posts about vbs

Related posts about vbscript