A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Different Versions of Object Libraries



 
 
Thread Tools Display Modes
  #11  
Old September 25th, 2007, 06:25 AM posted to comp.databases.ms-access,microsoft.public.access,microsoft.public.access.activexcontrol,microsoft.public.access.modulesdaovba
ARC[_3_]
external usenet poster
 
Posts: 14
Default 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]" wrote in message
...
"Phil Reynolds" 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/


  #12  
Old September 25th, 2007, 07:11 AM posted to comp.databases.ms-access,microsoft.public.access,microsoft.public.access.activexcontrol,microsoft.public.access.modulesdaovba
Phil Reynolds
external usenet poster
 
Posts: 54
Default 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]" wrote in message
...
"Phil Reynolds" 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/



  #13  
Old September 25th, 2007, 11:54 AM posted to comp.databases.ms-access,microsoft.public.access,microsoft.public.access.activexcontrol,microsoft.public.access.modulesdaovba
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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" wrote in message
. ..
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]" wrote in message
...
"Phil Reynolds" 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/




  #14  
Old September 25th, 2007, 12:14 PM posted to comp.databases.ms-access,microsoft.public.access,microsoft.public.access.activexcontrol,microsoft.public.access.modulesdaovba
Rick Brandt
external usenet poster
 
Posts: 4,354
Default 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


  #15  
Old September 25th, 2007, 01:00 PM posted to comp.databases.ms-access,microsoft.public.access,microsoft.public.access.activexcontrol,microsoft.public.access.modulesdaovba
lyle
external usenet poster
 
Posts: 23
Default Different Versions of Object Libraries

On Sep 24, 7:22 pm, "Phil Reynolds" 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?

  #16  
Old September 25th, 2007, 01:58 PM posted to comp.databases.ms-access,microsoft.public.access,microsoft.public.access.activexcontrol,microsoft.public.access.modulesdaovba
Rick Brandt
external usenet poster
 
Posts: 4,354
Default 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




  #17  
Old September 25th, 2007, 09:07 PM posted to comp.databases.ms-access,microsoft.public.access,microsoft.public.access.activexcontrol,microsoft.public.access.modulesdaovba
Tony Toews [MVP]
external usenet poster
 
Posts: 3,776
Default Different Versions of Object Libraries

"ARC" 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/
  #18  
Old September 25th, 2007, 09:07 PM posted to comp.databases.ms-access,microsoft.public.access,microsoft.public.access.activexcontrol,microsoft.public.access.modulesdaovba
Tony Toews [MVP]
external usenet poster
 
Posts: 3,776
Default 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. 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/
  #19  
Old September 26th, 2007, 07:24 AM posted to comp.databases.ms-access,microsoft.public.access,microsoft.public.access.activexcontrol,microsoft.public.access.modulesdaovba
Phil Reynolds
external usenet poster
 
Posts: 54
Default Different Versions of Object Libraries (CORRECTION)

Got it. Thanks!

"Rick Brandt" wrote in message
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






  #20  
Old September 26th, 2007, 07:25 AM posted to comp.databases.ms-access,microsoft.public.access,microsoft.public.access.activexcontrol,microsoft.public.access.modulesdaovba
Phil Reynolds
external usenet poster
 
Posts: 54
Default Different Versions of Object Libraries

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

"lyle" wrote in message
oups.com...
On Sep 24, 7:22 pm, "Phil Reynolds" 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?



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:26 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.