ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reference lost when newer version opens file (https://www.excelbanter.com/excel-programming/346132-reference-lost-when-newer-version-opens-file.html)

Rob

Reference lost when newer version opens file
 
I have a workbook that uses the Outlook 9 ilbrary. If someone opens the book
using office 10 then the reference gets updated to Outlook 10, which is fine
until I open it again in Office 9 and have to mannually tell it to look at
the version 9 library. Is there an easy way to fix this?

Thanks

Rob

Tom Ogilvy

Reference lost when newer version opens file
 
Possibly use late binding and not create a reference

Update the reference with code

--
Regards,
Tom Ogilvy


"Rob" wrote in message
...
I have a workbook that uses the Outlook 9 ilbrary. If someone opens the

book
using office 10 then the reference gets updated to Outlook 10, which is

fine
until I open it again in Office 9 and have to mannually tell it to look at
the version 9 library. Is there an easy way to fix this?

Thanks

Rob




Rob

Reference lost when newer version opens file
 
Thank you Tom

Here's the code if anyone's interested:

Private Sub Workbook_Open()
'delete existing Outlook reference
Dim Reference
For Each Reference In VBProject.References
If Reference.Name = "Outlook" Then VBProject.References.Remove(Reference)
Next
'set the Version 9 outlook reference
' I copied the file from c:\Program Files\Microsoft Office\Office\ to a
network drive
VBProject.References.AddFromFile ("N:\VBA\MSOUTL9.OLB")
End Sub




"Tom Ogilvy" wrote:

Possibly use late binding and not create a reference

Update the reference with code

--
Regards,
Tom Ogilvy


"Rob" wrote in message
...
I have a workbook that uses the Outlook 9 ilbrary. If someone opens the

book
using office 10 then the reference gets updated to Outlook 10, which is

fine
until I open it again in Office 9 and have to mannually tell it to look at
the version 9 library. Is there an easy way to fix this?

Thanks

Rob





Dave Peterson

Reference lost when newer version opens file
 
You might want to look at the way Dick Kusleika does it:
http://www.dicks-clicks.com/excel/olBinding.htm

You may want to look at these links that Tom Ogilvy posted recently:

Here are some more extensive references on binding:

Use late binding - don't have a reference to excel.

http://support.microsoft.com/default...b;EN-US;244167
INFO: Writing Automation Clients for Multiple Office Versions

http://support.microsoft.com/default...b;en-us;245115
INFO: Using Early Binding and Late Binding in Automation

http://support.microsoft.com/default...b;en-us;247579
INFO: Use DISPID Binding to Automate Office Applications Whenever Possible

==
I don't think Tom suggested what you used.


Rob wrote:

Thank you Tom

Here's the code if anyone's interested:

Private Sub Workbook_Open()
'delete existing Outlook reference
Dim Reference
For Each Reference In VBProject.References
If Reference.Name = "Outlook" Then VBProject.References.Remove(Reference)
Next
'set the Version 9 outlook reference
' I copied the file from c:\Program Files\Microsoft Office\Office\ to a
network drive
VBProject.References.AddFromFile ("N:\VBA\MSOUTL9.OLB")
End Sub

"Tom Ogilvy" wrote:

Possibly use late binding and not create a reference

Update the reference with code

--
Regards,
Tom Ogilvy


"Rob" wrote in message
...
I have a workbook that uses the Outlook 9 ilbrary. If someone opens the

book
using office 10 then the reference gets updated to Outlook 10, which is

fine
until I open it again in Office 9 and have to mannually tell it to look at
the version 9 library. Is there an easy way to fix this?

Thanks

Rob





--

Dave Peterson


All times are GMT +1. The time now is 05:08 AM.

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