You will want to change how you code your application so that you can use
Late Binding. Late Binding will get the appropriate object library which is
determined by the user.
Late Bound:
Dim objWord as Object
Set objWord=CreateObject("Word.Application")
objWord.Visible=True
objWord.Documents.Add
objWord.Quit
Set objWord=Nothing
Early Bound:
Dim objWord As New Word.Application
objWord.Visible = True
objWord.Documents.Add
objWord.Quit
There have been a couple of times where I needed to use Late Binding. These
instances have been when I did not know which version of Outlook I would be
attaching to. I would set my variable to Early Binding, so I would have the
intellisense that I needed while programming, and then when I was ready to
distribute the code, I'd change the variable so that it would be looking for
Late Binding. Here is my code sample, perhaps it will help:
#If EarlyBinding = 1 Then
Public objOLapp As Outlook.Application
Public objOLitem As Outlook.MailItem
#Else
Public objOLapp As Object
Public objOLitem As Object
#End If
Sub CombineEmailAddresses()
Dim strCell As String
Dim strEmail As String
Dim strActiveSheetName As String
On Error GoTo EH
'Sort the blank email addresses to the end of the list
Selection.Sort Key1:=Range("M2"), Order1:=xlAscending,
Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
'Position the cursor at the first email address
Application.GoTo Reference:="R2C13"
'Loop through all the addresses and combine them
Do While ActiveCell.Value <> ""
strCell = ActiveCell.Value
strEmail = strEmail & strCell & "; "
ActiveCell.Offset(1, 0).Range("A1").Select
Loop
Debug.Print strEmail
'Return the sort to how it was before
Selection.Sort Key1:=Range("a2"), Order1:=xlAscending,
Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Test (strEmail)
'Handle Errors Gracefully
Exit_EH:
Exit Sub
EH:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_EH
End Sub
Sub Test(strEmail As String)
On Error GoTo EH
Dim objOLapp As Object
Dim objOLitem As Object
Set objOLapp = CreateObject("Outlook.Application")
Set objOLitem = objOLapp.CreateItem(0)
With objOLitem
.Subject = ""
.CC = ""
.To = ""
.Body = ""
.bcc = strEmail
' .Attachments.Add '(path to the attachment,either hard coded or
variable)
.Display
End With
Set objOLapp = Nothing
Set objOLitem = Nothing
'Handle Errors Gracefully
Exit_EH:
Exit Sub
EH:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_EH
End Sub