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. |
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|