Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 6
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
xlsx file conversion Mark1 Excel Discussion (Misc queries) 1 January 23rd 08 02:30 AM
Convert Excel 2007 format (*.xlsx) into Excel 2003 format JD Moss Excel Discussion (Misc queries) 2 September 27th 07 06:46 PM
How do I convert a .xlsx file to .xls Reno Raines Excel Discussion (Misc queries) 2 September 12th 07 05:48 PM
xlsx file to xls Adam Excel Discussion (Misc queries) 1 January 9th 07 07:45 AM
how to format excel format to text format with separator "|" in s. azlan New Users to Excel 1 January 31st 05 12:57 PM


All times are GMT +1. The time now is 09:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"