Late Binding

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,124
Question:

I have been using late binding for a while now to reference the OL Object Model in an open event. I might be being dumb (likely) but even if I use late binding to create the object, which I then in turn use to mail the workbook itself to another user, then the object reference is mailed with the file also is it not? Is there any way to avoid this? Because if the next user has v9.0 and I had v10.0 then because the file has a reference already assigned to it for OL 10.0 olb (when it was mailed) then it will fall over on my machine with a missing reference. I hope I am missing some blatant knowledge here? It doesn't really matter if I am right or wrong as I am moving this out of VBA anyway BUT I am just interested to know what the solutions are?

Cheers and apologies if this makes little or no sense but why spoil the trend?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Is there any need to leave the code in place when you email it? Could you not just remove the code and the reference before sending it on?
 
Upvote 0
Well, you could remove the need for the reference from the get go...

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> SendMailViaOutlook()
    <SPAN style="color:#00007F">Dim</SPAN> appOutlook <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> MailItem <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>
    
    <SPAN style="color:#00007F">Set</SPAN> appOutlook = GetObject(, "Outlook.Application")
    <SPAN style="color:#00007F">Set</SPAN> MailItem = appOutlook.CreateItem(0)
    
    <SPAN style="color:#00007F">With</SPAN> MailItem
        .<SPAN style="color:#00007F">To</SPAN> = "joesmith@domain.com"
        .Send
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
    
    <SPAN style="color:#00007F">Set</SPAN> MailItem = <SPAN style="color:#00007F">Nothing</SPAN>
    <SPAN style="color:#00007F">Set</SPAN> appOutlook = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

This fairly simple example needs no references to be set.
 
Upvote 0
what do the major & minor settings do for the GUID - without them you can't add the reference... intrigued.
 
Upvote 0

Forum statistics

Threads
1,214,873
Messages
6,122,029
Members
449,061
Latest member
TheRealJoaquin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top