set Library References at Startup

tadropik

Registered User.
Local time
Today, 06:27
Joined
Jun 24, 2010
Messages
14
Is is possible to set my library references at Application Startup?
I have an application that needs to run on a 2003 platform and a 2007 platform.
The application refers to Word and Excel libraries.
I'd prefer not to use a macro to do this.

Tom
 
Not really, if the libraries are missing the code won't compile and hence won't run. You can and should use late binding when using Excel and Word automation in production, this would resolve the versioning issue you are running into as you would no longer need to have the libraries referenced.

Search for Late Binding in the forum there are tons of examples.
 
Thanks for the quick response DJKarl.

I tried Late binding and it works great for Excel and Word.

I can't seem to get it to work with Outlook.

(forgot to mention I call on Outlook too) :rolleyes:
 
Where is it blowing up with the Outlook code?
 
It should work with outlook too, but we'd need to see the code you are using.
 
I was using some old code. I changed it and got it to work.
See below...

Old code:
Dim objOutlook
Dim ojbOutlookMsg
Dim objOutlookRecip
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add("Joe@Testing.com")
objOutlookRecip.Type = olTo
.Subject = "Test Email"
.Body = sBody
.Send
End With 'objOutlookMsg

New Code:
Dim objOutlook
Dim ojbOutlookMsg
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.To = "Joe@Testing.com"
.Subject = "Test Email"
.Body = sBody
.Send
End With 'objOutlookMsg
 
You should declare with a type not just Dim something.

You should use

Dim objOutlook As Object
Dim ojbOutlookMsg As Object
 

Users who are viewing this thread

Back
Top Bottom