Urgent - VBA Office References Matching Versions

JaedenRuiner

Registered User.
Local time
Today, 11:14
Joined
Jun 22, 2005
Messages
154
I really need to know quick, if I assign the reference Microsoft Excel 11.0 Object Library to the vb side of the access application, what will happen if the access database is opened on a system that only has Office 2007 installed? See I know that version 11.0 is office 2003, so Excel 11.0 is Excel 2003, but if I add the reference to the 2003 library, will that crash the application because office 2007 (excel 12.0) is installed, or does Excel 12.0 also support Excel 11.0

Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
 
If you set a reference to a lower version, it will automatically upgrade to the later if that person has the later version. But if you have it set for a later version it can't set it backwards.

The best way is to use LATE BINDING so you don't even need a reference set and that way it works with any version.
 
Where would i find out how to do late binding of the Excel object.
Basically, all i need is to get a list of the WorkSheet names from an excel file. In .Net this excruciatingly simple to do, (provided you have the PIAs) but i'm a little rusty on my VBA.

Thanks
J"SD"a'RR
 
Where would i find out how to do late binding of the Excel object.
Basically, all i need is to get a list of the WorkSheet names from an excel file. In .Net this excruciatingly simple to do, (provided you have the PIAs) but i'm a little rusty on my VBA.

Thanks
J"SD"a'RR

Code:
Function GetWorksheetNames(strFileName As String) As String
    Dim objXL As Object
    Dim xlWB As Object
    Dim xlWS As Object
    Dim strSheets As String

    Set objXL = CreateObject("Excel.Application")
    Set xlWB = objXL.Workbooks.Open(strFileName)

    For Each xlWS In xlWB.Worksheets

        strSheets = strSheets & xlWS.Name & ", "
    Next xlWS
    strSheets = Left(strSheets, Len(strSheets) - 2)
    objXL.Quit
    Set objXL = Nothing
    GetWorksheetNames = strSheets
End Function
 

Users who are viewing this thread

Back
Top Bottom