Workbook code works on my machine but noy others

J

John

Hi,

I've got a Workbook i distribute to users. For some reason the WB is
crashing only with some of my users. I get the error
"Object Library Invalid or contains references to object definitions
thatcould not be found"

I've checked the reference ticked in VBE which are:

Visual Basic for Applications
Microsoft Excel 10.0 Object Library
OLE Automation
Microsoft Office 10.0 Object Library
Microsoft Forms 2.0 Object Library
Microsoft Windows Common Controls-2 6.0 (SP6)
Microsoft Outlook 10.0 Object Library
Microsoft Windows Common Controls 6.0 (SP6)

Weird as the application works ok on some machines but not other
Any ideas on this are very welcome.
Thanks guys,
John
 
J

Jacob Skaria

All user machines need to have the same version of references..In one of the
machines which return the error check VBE>Tools>References to see which one
is missing in that machine..

If this post helps click Yes
 
J

Joel

Sometimes excel doesn't recognize the reference libraries and you had to
browse for the librarry file even though it appears to be correct. This
happens often with the Ref Edit Control in particular but can happen with
other libraries.
 
J

John

Hi Jacob,

intersting comment!! I did notice that one of the references was version 3
on mine and version 2 on the users. Guess from what you're saying this can
make a difference.
So a follow up question is, would i need to uncheck it and then add it again?

Thanks
Regards,
John
 
J

Jacob Skaria

Just try browsing the control again if it is available in that machine...

If this post helps click Yes
 
J

JP Ronse

Hi John,

Jacob's suggestion is far the easiest way to solve your issue but will only
work when each user has his own version of the file. IMHO you will still
have the problem when you share the same workook.

You can of course upgrade each system to the same (highest) version but
even this does not gurantee that it stays working over a longer period of
time. (One has installed an higher version, the other not and the problem
reoccurs.

An alternative is to rewrite the code without including references.

The code below creates a meeting request in Outlook. As I don't have the
Outlook reference in the project, I had to define each constant.

My approach:
- Include the reference
- Write and test the code
- Lookup the values of the used constants in the object browser (View Menu)
- Remove the reference
- Declare the needed constants and adapt your code to late binding. In this
example, gobjOutlook is defined as object an not as outlook.application.


Wkr,

JP


Sub MultipleAppointment(Addressee, AddresseeOptional, OnDate, StartTime,
EndTime, Subject, PrivateAPP, Location, BusyState, _
Recurrent, Interval, EndBy)
Const olPRIVATE As Long = 2 ''' Outlook constant
Const olRequired As Long = 1
Const olOptional As Long = 2
Const olRecursWeekly As Long = 1

Dim blnJP As Boolean, blnBusyState As Boolean
Dim gobjOptionalAttendees As Object
Dim strOptionalAddressee As String
Dim olRecurrencePattern As Object


Set gobjOutlook = GetObject(, "Outlook.application")

Set gobjAppointment = gobjOutlook.CreateItem(olAppointmentItem)
With gobjAppointment
.MeetingStatus = olMeeting

.Start = OnDate + TimeValue(StartTime)
If (OnDate + TimeValue(EndTime)) <= .Start Then
.End = OnDate + 1 + TimeValue(EndTime)
Else
.End = OnDate + TimeValue(EndTime)
End If

If Recurrent = True Then
Set olRecurrencePattern = .GetRecurrencePattern
olRecurrencePattern.RecurrenceType = olRecursWeekly
olRecurrencePattern.Interval = Interval
olRecurrencePattern.PatternStartDate = OnDate
olRecurrencePattern.PatternEndDate = CDate(EndBy)
 
R

ryguy7272

Look here:
http://www.cpearson.com/excel/References.htm

If you see anything that says 'MISSING' uncheck it and check the correct
version. if you don't know what you have, run this code:
Sub ReturnExcelVersion()
If Application.Version = "12.0" Then
MsgBox "You are using Excel 2007."
ElseIf Application.Version = "11.0" Then
MsgBox "You are using Excel 2003."
ElseIf Application.Version = "10.0" Then
MsgBox "You are using Excel 2002."
ElseIf Application.Version = "9.0" Then
MsgBox "You are using Excel 2000."
ElseIf Application.Version = "8.0" Then
MsgBox "You are using Excel 97."
ElseIf Application.Version = "7.0" Then
MsgBox "You are using Excel 95."
End If
End Sub

Just saw it posted yesterday; very nice.

You may want to consider using late binding, as described here:
http://www.dicks-clicks.com/excel/olBinding.htm

HTH,
Ryan---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top