How do you have the object Dim'd in the first three lines of code? You could simply pass it as an Object: Function Get_Columns_and_Rows( ... , ExcelDoc As Object) As Integer Or you could load a reference to the Excel library and declare it Excel.Workbook. John Viescas, author Building Microsoft Access Applications Microsoft Office Access 2003 Inside Out Running Microsoft Access 2000 SQL Queries for Mere Mortals http://www.viescas.com/ (Paris, France) For the inside scoop on Access 2007, see: http://blogs.msdn.com/access/
_____ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of wharmon97 Sent: Wednesday, July 05, 2006 6:31 PM To: [email protected] Subject: [MS_AccessPros] How to pass an Excel object as a parameter of a function in vba I have a vba function "Get_Columns_and_Rows" to which I would like to pass an Excel object defined as strExcelDoc = "C:\Documents and Settings\wharmon\Desktop\Rapid ILL for Will\B200507.xls" Set ExcelDoc = ExcelApp.Workbooks.Open(strExcelDoc) My function: Function Get_Columns_and_Rows(ByRef intRow As Integer, ByRef intCol As Integer, ExcelDoc) As Integer On Error GoTo Err_Get_Columns_and_Rows .... So, anyone know how to reference the Excel object (ExcelDoc) as a function parameter? [Non-text portions of this message have been removed] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/ms_access/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
