counterrojo
11-09-2011, 04:17 PM
Hi,
I am trying to use a macro on my Win 7 64bit machine. This code works on my xp machine. I get run-time error '429': ActiveX component can't create object on: Set oOutlookApp = GetObject(, "Outlook.Application"). I'm wondering if this is a 64 bit problem or if something else is causing it. The macro is supposed to email a word document:
Option Explicit
Private Sub CommandButton1_Click()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If
On Error GoTo 0
ActiveDocument.Save
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.To = "FinanceShiningStars@davita.com"
.Subject = "Completed Finance Shining Star Core Value Pin Form"
'Add the document as an attachment, you can use the .displayname property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
DisplayName:="Document as attachment"
.Display
End With
If bStarted Then
oOutlookApp.Quit
End If
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
Thanks,
Michael
I am trying to use a macro on my Win 7 64bit machine. This code works on my xp machine. I get run-time error '429': ActiveX component can't create object on: Set oOutlookApp = GetObject(, "Outlook.Application"). I'm wondering if this is a 64 bit problem or if something else is causing it. The macro is supposed to email a word document:
Option Explicit
Private Sub CommandButton1_Click()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If
On Error GoTo 0
ActiveDocument.Save
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.To = "FinanceShiningStars@davita.com"
.Subject = "Completed Finance Shining Star Core Value Pin Form"
'Add the document as an attachment, you can use the .displayname property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
DisplayName:="Document as attachment"
.Display
End With
If bStarted Then
oOutlookApp.Quit
End If
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
Thanks,
Michael