ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Have end user add missing references without accessing the vba pro (https://www.excelbanter.com/excel-programming/355481-have-end-user-add-missing-references-without-accessing-vba-pro.html)

Mariano B.

Have end user add missing references without accessing the vba pro
 
I use Office 2003 but most of the end-users for my application have office XP.

The application uses the outlook object library. the problem is that since I
have office 2003, it references version 11 of the library. I have the
following code to try to avoid this problem.

Private Sub ReferenciaXP()
Dim str As String
Dim v As Integer
Dim i As Integer
Set Refs = Application.VBE.VBProjects(1).References
v = Application.Version
If v < 10 Then
MsgBox "Esta aplicación solo esta hecha para Office XP o superior",
vbInformation + vbOKOnly, "xMedios"
ActiveWorkbook.Close
Else
If v = 10 Then
For i = 1 To Refs.Count
If Refs(i).IsBroken And Refs(i).name = "Outlook" Then
Application.VBE.VBProjects(1).References.Remove Refs(i)
End If
Next i
str = Application.Path & "\msoutl.olb"
Application.VBE.ActiveVBProject.References.AddFrom File (str)
End If
End If

End Sub


But it does not work on all machines.
Sometimes the user is missing more references that are needed. I'd like it
if there was a way that the user could add the missing references without
having access to the proyect.

Any ideas??



--
Mariano

Ron de Bruin

Have end user add missing references without accessing the vba pro
 
Hi Mariano

You can use late binding
See the info on the bottom of this outlook example
http://www.rondebruin.nl/mail/folder2/mail1.htm

Read the info on Dick's site also


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Mariano B." wrote in message ...
I use Office 2003 but most of the end-users for my application have office XP.

The application uses the outlook object library. the problem is that since I
have office 2003, it references version 11 of the library. I have the
following code to try to avoid this problem.

Private Sub ReferenciaXP()
Dim str As String
Dim v As Integer
Dim i As Integer
Set Refs = Application.VBE.VBProjects(1).References
v = Application.Version
If v < 10 Then
MsgBox "Esta aplicación solo esta hecha para Office XP o superior",
vbInformation + vbOKOnly, "xMedios"
ActiveWorkbook.Close
Else
If v = 10 Then
For i = 1 To Refs.Count
If Refs(i).IsBroken And Refs(i).name = "Outlook" Then
Application.VBE.VBProjects(1).References.Remove Refs(i)
End If
Next i
str = Application.Path & "\msoutl.olb"
Application.VBE.ActiveVBProject.References.AddFrom File (str)
End If
End If

End Sub


But it does not work on all machines.
Sometimes the user is missing more references that are needed. I'd like it
if there was a way that the user could add the missing references without
having access to the proyect.

Any ideas??



--
Mariano





All times are GMT +1. The time now is 12:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com