Title: Calling Method, Setting Property in VBA in Excel
Platforms: | Windows NT 3.51, 4.0, Windows 95 |
Requirements: | Office97 app, OLE control |
Sample Apps: | Microsoft Excel97, MFC Control Wizard generated control |
Test Category: | CONTROL |
Overview:
This sample code illustrates adding a 'test' control, and calling methods and setting properties on that control from VBA. Obviously the properties and methods will vary by control.
Steps:
'------------------------------------
'Excel
Sub Test()
Set myDocument = Worksheets(1)
myDocument.Shapes.AddOLEObject Left:=100, Top:=100, Width:=100, _ Height:=200, ClassType:="O97CTRL.O97TestCtrl.1"
ActiveSheet.OLEObjects(1).Object.AboutBox
ActiveSheet.OLEObjects(1).Object.MyMethod
Debug.Print Str(ActiveSheet.OLEObjects(1).Object.ReadyState)
OLEObjects(1).Object.Caption = "test1"
Debug.Print OLEObjects(1).Object.Caption
End Sub
Result:
Control added to sheet, properties and methods invoked successfully.
Summary:
This tests whether the control can be manipulated from VBA.