Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / January 2005

Tip: Looking for answers? Try searching our database.

Late Binding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom - 27 Jan 2005 17:59 GMT
Using Office XP and wish to email to Outlook from Access using vba - am
advised that usage of late binding would be preferable rather that setting
reference to Outlook

Does anyone have an example of the appropriate code please

TIA

Tom
Michael Bauer - 28 Jan 2005 06:31 GMT
Hi Tom,

Late Binding means that you declare all object variables As Object
instead of the proper object type. In this case you don´t need to
reference the Outlook library.

Anyway, if you are not familiar with the OOM, I would suppose that you
set a refenrence on Outlook while developing. After developing you can
remove this. Only with a reference set you can use the object browser
(F2), which shows you all available methods etc.

Create an Outlook instance with the CreateObject method, a MailItem with
the CreateItem method. Declarations and samples for using these methods
you will find easily via the object browser.

Please see also http://www.outlookcode.com/d/sec.htm for the upcoming
security warnings.

Signature

Viele Grüße
Michael Bauer

> Using Office XP and wish to email to Outlook from Access using vba - am
> advised that usage of late binding would be preferable rather that setting
[quoted text clipped - 5 lines]
>
> Tom
Bingo - 28 Jan 2005 14:30 GMT
The project I just finished is using late-binding.  The
only reason is to simplify the auto build process to
support different versions of Outlook.  

The code would look like:

Dim oApp ' VBA
Dim oApp As Object ' VB6

Set oApp = CreateObject("Outlook.Application")

...

Set oApp = Nothing

>-----Original Message-----
>Hi Tom,
[quoted text clipped - 28 lines]
>
>.
Michael Bauer - 28 Jan 2005 15:15 GMT
Hi Bingo,

> Dim oApp ' VBA

For VBS, ok, but why for VBA?

Signature

Viele Grüße
Michael Bauer

The project I just finished is using late-binding.  The
only reason is to simplify the auto build process to
support different versions of Outlook.

The code would look like:

Dim oApp As Object ' VB6

Set oApp = CreateObject("Outlook.Application")

...

Set oApp = Nothing

>-----Original Message-----
>Hi Tom,
>
>Late Binding means that you declare all object variables
As Object
>instead of the proper object type. In this case you
don´t need to
>reference the Outlook library.
>
>Anyway, if you are not familiar with the OOM, I would
suppose that you
>set a refenrence on Outlook while developing. After
developing you can
>remove this. Only with a reference set you can use the
object browser
>(F2), which shows you all available methods etc.
>
>Create an Outlook instance with the CreateObject method,
a MailItem with
>the CreateItem method. Declarations and samples for
using these methods
>you will find easily via the object browser.
>
>Please see also http://www.outlookcode.com/d/sec.htm for
the upcoming
>security warnings.
>
>> Using Office XP and wish to email to Outlook from
Access using vba -
>am
>> advised that usage of late binding would be preferable
rather that
>setting
>> reference to Outlook
>>
>> Does anyone have an example of the appropriate code
please

>> TIA
>>
>> Tom
>
>.
Bingo - 28 Jan 2005 19:43 GMT
VBScript indeed.  :-)

>-----Original Message-----
>Hi Bingo,
[quoted text clipped - 62 lines]
>
>.
Tom - 29 Jan 2005 07:47 GMT
Thanks for your input, have tried your suggestions as per code below - it
will not compile last line saying user type not defined - what do I have to
declare olMailItem as?

   Dim objOutlook As Object
  Dim objOutlookMsg As Object
  Dim objOutlookRecip As Object
  Dim objOutlookAttach As Object

  Set objOutlook = CreateObject("Outlook.Application")

  Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

Tom

VBScript indeed.  :-)

>-----Original Message-----
>Hi Bingo,
>
>> Dim oApp ' VBA
>
>For VBS, ok, but why for VBA?

message
>news:088b01c50545$eb2b1a40$a501280a@phx.gbl...
>
[quoted text clipped - 57 lines]
>
>.
Michael Bauer - 29 Jan 2005 09:37 GMT
Hi Tom,

>    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

with late binding you need to declare your own constants, i.e.
olMailItem from the Outlook Library is unknown for your app.

Signature

Viele Grüße
Michael Bauer

> Thanks for your input, have tried your suggestions as per code below - it
> will not compile last line saying user type not defined - what do I have to
[quoted text clipped - 82 lines]
> >
> >.
Tom - 29 Jan 2005 09:43 GMT
Michael

Can you give me an example as to the best way to do this please

Tom
> Hi Tom,
>
[quoted text clipped - 91 lines]
>> >
>> >.
Michael Bauer - 29 Jan 2005 15:41 GMT
Hi Tom,

sorry, VBS is not my language and I´ve just read that constants aren´t
possible. That is you need to use the numeric value (0 for olMailItem).

Signature

Viele Grüße
Michael Bauer

> Michael
>
[quoted text clipped - 7 lines]
> > with late binding you need to declare your own constants, i.e.
> > olMailItem from the Outlook Library is unknown for your app.
Tom - 29 Jan 2005 18:03 GMT
Michael

Where can I find the numeric values for or do you know them for:

   olTo
   olCC
   olBCC

tia

Tom
> Hi Tom,
>
[quoted text clipped - 12 lines]
>> > with late binding you need to declare your own constants, i.e.
>> > olMailItem from the Outlook Library is unknown for your app.
Michael Bauer - 29 Jan 2005 18:21 GMT
Hi Tom,

please set (for developing purposes only) a reference on the Outlook x.0
Library and open the object browser, as i mentioned earlier. You can
then type in all the constants you need and see their values below in
the description pane.

Signature

Viele Grüße
Michael Bauer

> Michael
>
[quoted text clipped - 3 lines]
>     olCC
>     olBCC
Tom - 29 Jan 2005 19:28 GMT
Michael

Brilliant!! - thanks very much for your help

Tom
> Hi Tom,
>
[quoted text clipped - 10 lines]
>>     olCC
>>     olBCC
Ken Slovak - 31 Jan 2005 14:57 GMT
Once you have those Const values you can then define them in your VBS code
if you want using a Const declaration. VBS does support constant
declarations.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Michael
>
> Brilliant!! - thanks very much for your help
>
> Tom
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.