Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ole Automation With VB

Status
Not open for further replies.

newbie1983

Programmer
Sep 9, 2003
52
GB
i would like to automate a vba program into vb. Id like to use an OLE object as an excel worksheet on the vb form but how do i 'communicate' with the object? ive set the relevent project/references. Will the following commands like textstream and xlcell.offset still be legal?

Regards
Hinesh
 
Use the control's Object property to return the Excel Workbook object itself from which you can code against the Excel object model in the usual way.

Paul Bent
Northwind IT Systems
 
Paul,

Can you show me some example code to illustrate that?

Regards ,
Hinesh
 
Project \ References \ Microsoft Excel 8.0 Object Library
Code:
Dim objXlApp As Excel.Application
Set objXlApp = New Excel.Application
... etc. ...
... etc. ...

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"A computer program does what you tell it to do, not what you want it to do." -- Greer's Third Law
 
No, that's not what the original question was asking nor what paulbent was saying.

[tt]
Option Explicit
Private WithEvents myExcel As Excel.Workbook

Private Sub Command1_Click()
myExcel.Activate
myExcel.ActiveSheet.Range("A1") = "All OK"
End Sub

Private Sub Form_Load()
Set myExcel = OLE1.object
End Sub
[/tt]


 
Paul,

OLE1 is the excelworksheet object. I cant seem to get it to work. Any ideas?

Private Sub Form_Load()
Dim objXlApp As Excel.Application
Set objXlApp = New Excel.Application

Me.OLE1.object = objXlApp

objXlApp.Cells(1, 0) = "testing"


End Sub


Kind Regards
Hinesh
 
Sorry, strongm, I'm not reading posts properly again. Perhaps I should take a remedial course.

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"A computer program does what you tell it to do, not what you want it to do." -- Greer's Third Law
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top