Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.newusers
|
|||
|
|||
Substituting a xls format with a xlsx format file
Hi:
I have piece of VBA code that populates a Word UserForm combobox from a external source (named range in an Excel file.) It works perfectly as is with Word2003 or Word2007 using a .xls Excel file extension. Here is the code: Private Sub UserForm_Initialize() Dim strOffice As String Dim i As Long Dim db As DAO.Database Dim rs As DAO.Recordset strOffice = "mySSRange" 'Open the file containing the Office Locations Set db = OpenDatabase(ThisDocument.Path & Application.PathSeparator & "GetData.xls", False, False, "Excel 8.0") 'Retrieve the recordset Set rs = db.OpenRecordset("SELECT * FROM `" & strOffice & "`") 'Determine the number of retrieved records With rs .MoveLast i = .RecordCount .MoveFirst End With 'Set the number of Columns = number of Fields in recordset cmbOfficeLocations.ColumnCount = rs.Fields.Count 'Load the combobox with the retrieved records cmbOfficeLocations.Column = rs.GetRows(i) 'Cleanup rs.Close db.Close Set rs = Nothing Set db = Nothing End Sub However, if I save the xls file as a Excel2007 format file with and xlsx extension and change "GetData.xls" to "GetData.xlsx" I get a RTE 3274 "External table is not in the expected format." If I change "Excel 8.0" to "Excel 12.0" I get a RTE 3170 Could not find installable ISAM" Can anyone tell how I would make this or similiar code work with an Excel2007 format file? Thanks. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Greg Maxey - Word MVP My web site http://gregmaxey.mvps.org Word MVP web site http://word.mvps.org ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
xlsx file conversion | Excel Discussion (Misc queries) | |||
Convert Excel 2007 format (*.xlsx) into Excel 2003 format | Excel Discussion (Misc queries) | |||
How do I convert a .xlsx file to .xls | Excel Discussion (Misc queries) | |||
xlsx file to xls | Excel Discussion (Misc queries) | |||
how to format excel format to text format with separator "|" in s. | New Users to Excel |