Toos --->References

  • Thread starter Thread starter Konstantin Loguinov
  • Start date Start date
K

Konstantin Loguinov

Folks,

I have a database that needs to have a reference to "Microsoft Office X.X
Object Library". The problem is that different computers have different
versions of Office installed and I get an error when I open the database.
So, I have to go and replace the reference with the correct one. It works,
but it's kind of time consuming and not very user friendly.

So, here is the question. Is it possible in VBA to check which version of
Office is installed and make appropriate changes if the database is
referencing a wrong version of object library?

Thanks!

Konstantin
 
Thanks for the suggestion!

Here is the exact code that I use to open an Outlook appointment window.

Dim spObj As Object
Dim MyItem As Object

Answer = MsgBox("Would you like to place an appointment into Outlook?",
vbYesNo, "Outlook Appointment")

If Answer = 6 Then
Set spObj = CreateObject("Outlook.Application")
Set MyItem = spObj.CreateItem(olAppointmentItem)
With MyItem
.Subject = "Call " + Me.FirstName & " " + Me.LastName + " (" +
Me.Company + ")"
.Start = Me.NextContact
.End = Me.NextContact
.Body = "Phone number:" & Me.Phone
End With

MyItem.Display
Set spObj = Nothing
End If

If I remove the reference, the code errors out on the
".Start=Me.NextContact" line. If I comment out that line and 2 lines below
it, the code works, but instead of an appointment window, it opens an email
message with the subject.

After reading the article you suggested and comparing the declarations with
my declarations, I'm not sure what could cause such behavior.

Thanks again for your help!

K
 
You need to use an actual value instead of olAppointmentItem...which is
unknown without a reference. The value is 1. Also, I'd suggest that you
insert Option Explicit in all your modules...if you had done so, this issue
would have been discovered during compile.
 
Paul,

Thank you! I can't believe I missed this one.

I'll go ahead and add Option Explicit right away.

K
 
Back
Top