Different Versions of Object Libraries

This is a discussion on Different Versions of Object Libraries within the Framework and Interface Programming forums in category; That sounds interesting! I've seen late-binding code for open file's, and fonts, etc., but never have seen the code for late binding on Outlook. Do you have a link, Tony? Many thanks, Andy "Tony Toews [MVP]" <ttoews @ telusplanet.net> wrote in message news:34tgf3d48hm0jtacvfe2mlu7nl3raai8jt @ 4ax.com... > "Phil Reynolds" <philr2354 @ msn.com> wrote: > >>I realize I could use late binding. But the code's already written, and >>I'd >>prefer not to have rewrite everything -- at least not at this point. > > FWIW Late Binding should only take ten minutes or half hour per > instance of using the Word ...

Go Back   Application Development Forum > Framework and Interface Programming

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #11  
Old 09-25-2007, 01:25 AM
ARC
Guest
 
Default Re: Different Versions of Object Libraries

That sounds interesting! I've seen late-binding code for open file's, and
fonts, etc., but never have seen the code for late binding on Outlook. Do
you have a link, Tony? Many thanks,

Andy
"Tony Toews [MVP]" <ttoews@telusplanet.net> wrote in message
news:34tgf3d48hm0jtacvfe2mlu7nl3raai8jt@4ax.com...
> "Phil Reynolds" <philr2354@msn.com> wrote:
>
>>I realize I could use late binding. But the code's already written, and
>>I'd
>>prefer not to have rewrite everything -- at least not at this point.

>
> FWIW Late Binding should only take ten minutes or half hour per
> instance of using the Word or Outlook libraries to implement. And
> it's quite stable. I have many clients running an app with late
> binding to Outlook and I know they don't have Outlook installed.
>
> Tony
> --
> Tony Toews, Microsoft Access MVP
> Please respond only in the newsgroups so that others can
> read the entire thread of messages.
> Microsoft Access Links, Hints, Tips & Accounting Systems at
> http://www.granite.ab.ca/accsmstr.htm
> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/


Reply With Quote
  #12  
Old 09-25-2007, 02:11 AM
Phil Reynolds
Guest
 
Default Re: Different Versions of Object Libraries

Thanks for that. But I'm a bit confused. They don't have Outlook installed?
I assume you're saying that they can run the app on a machine without
Outlook installed, but they can't actually use the functions that use
Outlook, right?

Thanks.


"Tony Toews [MVP]" <ttoews@telusplanet.net> wrote in message
news:34tgf3d48hm0jtacvfe2mlu7nl3raai8jt@4ax.com...
> "Phil Reynolds" <philr2354@msn.com> wrote:
>
>>I realize I could use late binding. But the code's already written, and
>>I'd
>>prefer not to have rewrite everything -- at least not at this point.

>
> FWIW Late Binding should only take ten minutes or half hour per
> instance of using the Word or Outlook libraries to implement. And
> it's quite stable. I have many clients running an app with late
> binding to Outlook and I know they don't have Outlook installed.
>
> Tony
> --
> Tony Toews, Microsoft Access MVP
> Please respond only in the newsgroups so that others can
> read the entire thread of messages.
> Microsoft Access Links, Hints, Tips & Accounting Systems at
> http://www.granite.ab.ca/accsmstr.htm
> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/



Reply With Quote
  #13  
Old 09-25-2007, 06:54 AM
Douglas J. Steele
Guest
 
Default Re: Different Versions of Object Libraries

To switch early binding code to late binding, you need to do the following:

1. Change any declarations to use Object rather than the specific object. In
other words, change

Dim objOutlook As Outlook.Application

to

Dim objOutlook As Object

2. Change how you instantiate the object from using the New keyword to using
CreateObject. In other words, change

Set objOutlook = New Outlook.Application

to

Set objOutlook = CreateObject("Outlook.Application")

3. Either replace any intrinsic constants from the formerly referenced
library with their actual values, or else define the constants in your
application. In other words, change

objOutlookRecip.Type = olTo

to either

objOutlookRecip.Type = 1

or

Const olTo As Long = 1

objOutlookRecip.Type = olTo

(this is usually the most time consuming part: making sure you've found all
the references to intrinsic constants, and that you know the actual value
for each one!)

Once you've done that, you can remove the reference under Tools |
References, and you should be okay. (The CreateObject statement will raise
an error 429 if the necessary libraries aren't present, so you have to trap
for that)

Take a look at the code in http://support.microsoft.com/?kbid=161088

Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olTo

' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Michael Suyama")
objOutlookRecip.Type = olCC

' Add the BCC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
objOutlookRecip.Type = olBCC

' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "This is the body of the message." &vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

' Resolve each Recipient's name.
For Each ObjOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
End Sub

Late Bound, that would be:

Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
' "Rule 1": Use Object in the declarations
Dim objOutlook As Object
Dim objOutlookMsg As Object
Dim objOutlookRecip As Object
Dim objOutlookAttach As Object

' "Rule 3": Define all instrinsic constants used from the specific object
model
Const olMailItem As Long = 0
Const olTo As Long = 1
Const olCC As Long = 2
Const olBCC As Long = 3
Const olImportanceHigh As Long = 2

' "Rule 2": Use CreateObject (which, you'll see, the original already did)
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olTo

' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Michael Suyama")
objOutlookRecip.Type = olCC

' Add the BCC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
objOutlookRecip.Type = olBCC

' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "This is the body of the message." &vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

' Resolve each Recipient's name.
For Each ObjOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing

End Sub

or

Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Object
Dim objOutlookMsg As Object
Dim objOutlookRecip As Object
Dim objOutlookAttach As Object

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(0)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = 1

' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Michael Suyama")
objOutlookRecip.Type = 2

' Add the BCC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
objOutlookRecip.Type = 3

' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "This is the body of the message." &vbCrLf & vbCrLf
.Importance = 2 'High importance

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

' Resolve each Recipient's name.
For Each ObjOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
End Sub


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"ARC" <PCESoft@PCESoft.invalid> wrote in message
news:EZ0Ki.542$ua4.162@newssvr22.news.prodigy.net. ..
> That sounds interesting! I've seen late-binding code for open file's, and
> fonts, etc., but never have seen the code for late binding on Outlook. Do
> you have a link, Tony? Many thanks,
>
> Andy
> "Tony Toews [MVP]" <ttoews@telusplanet.net> wrote in message
> news:34tgf3d48hm0jtacvfe2mlu7nl3raai8jt@4ax.com...
>> "Phil Reynolds" <philr2354@msn.com> wrote:
>>
>>>I realize I could use late binding. But the code's already written, and
>>>I'd
>>>prefer not to have rewrite everything -- at least not at this point.

>>
>> FWIW Late Binding should only take ten minutes or half hour per
>> instance of using the Word or Outlook libraries to implement. And
>> it's quite stable. I have many clients running an app with late
>> binding to Outlook and I know they don't have Outlook installed.
>>
>> Tony
>> --
>> Tony Toews, Microsoft Access MVP
>> Please respond only in the newsgroups so that others can
>> read the entire thread of messages.
>> Microsoft Access Links, Hints, Tips & Accounting Systems at
>> http://www.granite.ab.ca/accsmstr.htm
>> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

>



Reply With Quote
  #14  
Old 09-25-2007, 07:14 AM
Rick Brandt
Guest
 
Default Re: Different Versions of Object Libraries

Phil Reynolds wrote:
> Thanks for that. But I'm a bit confused. They don't have Outlook
> installed? I assume you're saying that they can run the app on a
> machine without Outlook installed, but they can't actually use the
> functions that use Outlook, right?


Correct. If they don't have Outlook installed with late binding your Outlook
code does not work. If they don't have Outlook installed with early binding the
whole application often does not work. The latter is obviously preferable.


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


Reply With Quote
  #15  
Old 09-25-2007, 08:00 AM
lyle
Guest
 
Default Re: Different Versions of Object Libraries

On Sep 24, 7:22 pm, "Phil Reynolds" <philr2...@msn.com> wrote:

> I realize I could use late binding. But the code's already written, and I'd
> prefer not to have rewrite everything -- at least not at this point.


This would might take thirty seconds, but not more than sixty!
You'd rather have your client screw around with misdirected
references?

Reply With Quote
  #16  
Old 09-25-2007, 08:58 AM
Rick Brandt
Guest
 
Default Re: Different Versions of Object Libraries (CORRECTION)

Rick Brandt wrote:
> Phil Reynolds wrote:
>> Thanks for that. But I'm a bit confused. They don't have Outlook
>> installed? I assume you're saying that they can run the app on a
>> machine without Outlook installed, but they can't actually use the
>> functions that use Outlook, right?

>
> Correct. If they don't have Outlook installed with late binding your
> Outlook code does not work. If they don't have Outlook installed
> with early binding the whole application often does not work. The
> latter is obviously preferable.

^^^^^
former


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com




Reply With Quote
  #17  
Old 09-25-2007, 04:07 PM
Tony Toews [MVP]
Guest
 
Default Re: Different Versions of Object Libraries

"ARC" <PCESoft@PCESoft.invalid> wrote:

>That sounds interesting! I've seen late-binding code for open file's, and
>fonts, etc., but never have seen the code for late binding on Outlook. Do
>you have a link, Tony?


"Late Binding in Microsoft Access" page at
http://www.granite.ab.ca/access/latebinding.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Reply With Quote
  #18  
Old 09-25-2007, 04:07 PM
Tony Toews [MVP]
Guest
 
Default Re: Different Versions of Object Libraries

"Phil Reynolds" <philr2354@msn.com> wrote:

>Thanks for that. But I'm a bit confused. They don't have Outlook installed?
>I assume you're saying that they can run the app on a machine without
>Outlook installed, but they can't actually use the functions that use
>Outlook, right?


Correct. And they don't get any reference errors or other such
problems.

Also this comes in very handy when part of your network has upgraded
to a newer version of Office/Outlook and part is still on the old
version.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Reply With Quote
  #19  
Old 09-26-2007, 02:24 AM
Phil Reynolds
Guest
 
Default Re: Different Versions of Object Libraries (CORRECTION)

Got it. Thanks!

"Rick Brandt" <rickbrandt2@hotmail.com> wrote in message
news:RB7Ki.28778$eY.17684@newssvr13.news.prodigy.n et...
> Rick Brandt wrote:
>> Phil Reynolds wrote:
>>> Thanks for that. But I'm a bit confused. They don't have Outlook
>>> installed? I assume you're saying that they can run the app on a
>>> machine without Outlook installed, but they can't actually use the
>>> functions that use Outlook, right?

>>
>> Correct. If they don't have Outlook installed with late binding your
>> Outlook code does not work. If they don't have Outlook installed
>> with early binding the whole application often does not work. The
>> latter is obviously preferable.

> ^^^^^
> former
>
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt at Hunter dot com
>
>
>
>



Reply With Quote
  #20  
Old 09-26-2007, 02:25 AM
Phil Reynolds
Guest
 
Default Re: Different Versions of Object Libraries

Really, sixty seconds? Maybe for extremely simple code. But I understand
your point. Thanks.

"lyle" <lyle.fairfield@gmail.com> wrote in message
news:1190721650.797606.195920@o80g2000hse.googlegr oups.com...
> On Sep 24, 7:22 pm, "Phil Reynolds" <philr2...@msn.com> wrote:
>
>> I realize I could use late binding. But the code's already written, and
>> I'd
>> prefer not to have rewrite everything -- at least not at this point.

>
> This would might take thirty seconds, but not more than sixty!
> You'd rather have your client screw around with misdirected
> references?
>



Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 03:15 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.