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!

Executing Excel OLE Object 1

Status
Not open for further replies.

bz6f5g

Technical User
Jan 18, 2004
1
US
I have created a table to store Excel spreadsheets that I will use as templates for Excel based reports. The spreadsheets are stored as type OLE Object in the Access 2003 table. Have stored the excel spreadsheets in the table. If you open the table and double click the cell that contains the spreadsheet, Excel launches and the spreadsheet is loaded.

My problem is I cannot figure out how to launch the spreadsheets from Access VBA so that I can write data to the spreadsheet. I keep getting type errors.

Any ideas?

Thanks,

Dean
 
What code are you trying to use?

I've had some minor success with this, it just depends on what you're trying to do.

Try something like this:

Private Sub cmdExcel_Click()
Dim objExl As Excel.Application, objWrkbk As Excel.Workbook

Me!oleExcelFile.Action = acOLEActivate

Set objExl = GetObject(, "Excel.Application")

For Each objWrkbk In objExl.Workbooks
If Left(objWrkbk.Name, 12) = "Worksheet in" Then
objWrkbk.ActiveSheet.Range("A1") = "I Work!"
Exit For
End If
Next objWrkbk

objWrkbk.Close
objExl.Quit
Set objWrkbk = Nothing
Set objExl = Nothing

End Sub


Kyle
 
Kyle, your post gave me EXACTLY the help I needed. I've been trying to figure out the details of this procedure since yesterday!
 
Glad you found it useful Gordon! Thanks for the star!

Kyle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top