Yeatman, Tony
Tony.Yeatman at creditlyonnais.co.uk
Thu Jun 5 09:03:17 CDT 2003
I have an Access 97 Application distributed as mde's, it is split into a series of Modules, including a code Module. There are references to both Excel and Outlook. As we will shortly be rolling out Office 2000, I will be unable to determine which version of Excel/Outlook will be installed, and are therefore going to change to late binding. In the code module i pass an excel object as a ByRef Parameter to a function (listed below) that populates the spreadsheet. As the code module will also need to be late binding i will need to change this to an object. How can I reference the Object and manipulate as an Excel Object within the function ? Any ideas or thoughts would be very much appreciated. Tony. Function fnExcel_WriteSheet(ByRef xlWorkbook As Excel.Workbook, strSQL As String, strSheetName As String) As Boolean Dim intCount As Integer Dim rstDAO As DAO.Recordset Dim fld As Field On Error GoTo Err_fnExcel_WriteSheet Set rstDAO = gDbDAO.OpenRecordset(strSQL, dbOpenSnapshot) xlWorkbook.Worksheets.Add xlWorkbook.ActiveSheet.Name = left(strSheetName, 30) xlWorkbook.ActiveSheet.Range("A2").CopyFromRecordset rstDAO intCount = 0 'For each field in the query (Client Grouping) add Grouping Number to the Column For Each fld In rstDAO.Fields xlWorkbook.ActiveSheet.Range("a1").Offset(0, intCount).Value = fld.Name xlWorkbook.ActiveSheet.Range("a1").Offset(0, intCount).EntireColumn.AutoFit intCount = intCount + 1 Next fld rstDAO.Close Set rstDAO = Nothing 'Format the Sheet fnExcel_Format xlWorkbook, intCount, 1 Exit_fnExcel_WriteSheet: Exit Function Err_fnExcel_WriteSheet: fnLogErr Resume Exit_fnExcel_WriteSheet End Function ************************************************************************* The information in this internet E-mail is confidential and is intended solely for the addressee. Access, copying or re-use of information in it by anyone else is unauthorized. Any views or opinions presented are solely those of the author and do not necessarily represent those of Credit Lyonnais or any of its affiliates. The information contained herein is recorded for business purposes and use of services is monitored to protect both the company and its individual users. If you are not the intended recipient please contact postmaster at creditlyonnais.co.uk ************************************************************************* -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030605/da61bce3/attachment.html>