Results 1 to 2 of 2
  1. #1
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,015
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Using the Microsoft Excel Worksheet Insertable Obj

    If you go to Components and Insertable objects in VB6
    There is a Microsoft Excel Worksheet Object

    I can put this on a form, but as per normal with Microsoft, the help and documentation
    are rubbish (alegedly)

    Does anyone know how to program this control or know of any web site that have help on it.
    I can get no sense out of Google, and I think potentially it might be a useful control and might mean NOT having to use assorted grids.

    On the other hand I might well be wrong there.

    Thanks
    Andrew

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Using the Microsoft Excel Worksheet Insertable Obj

    Sorry about the late reply. Perhaps the following will give you something to start with. It assumes that the control containing the worksheet object is named OLE1 and that you have a command button Command1 with the following On Click event procedure:

    Private Sub Command1_Click()
    Dim xlWbk As Object ' Excel.Workbook
    Me.OLE1.DoVerb -5
    Set xlWbk = Me.OLE1.Object
    MsgBox xlWbk.ActiveSheet.Range("A1").Value
    Me.Command1.SetFocus
    xlWbk.Application.Quit
    Set xlWbk = Nothing
    End Sub

    If you want IntelliSense for the Excel object, you must set a reference to the Microsoft Excel v.0 Object Library (in Project | References...), where v is the version you use (8 = Excel 97, 9 = Excel 2000, 10 = Excel 2002/XP and 11 = Excel 2003), and declare xlWbk as Excel.Workbook instead of as Object.

    See IOleObject:oVerb for info on DoVerb.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •