Hi All (also asked here)
I have a complicated set of code that runs from Outlook, into excel and then in excel runs this code below:
This code works, but every so often the users get the Run Time error mentioned in the thread title... I did some googling and I found this page on a similar error regarding to Word: You may receive the "Run-time error '-2147023174' (800706ba)" error message or the "Run-time error '462'" when you run Visual Basic code that uses Automation to control Word
It looks like it would relate to my error but replace word with outlook... It seems to say that a hidden global variable reference is created and that its not released between each runs of the code?
I tried to understand all that the link above said in relation to my code, but well I just don't understand it... Could one of you guru's fix my code above??
Thanks in advance
I have a complicated set of code that runs from Outlook, into excel and then in excel runs this code below:
Code:
Dim objOutl
Set objOutl = CreateObject("Outlook.Application")
Set objMailItem = objOutl.CreateItem(olMailItem)
Application.ScreenUpdating = False
ans = MsgBox("Do you need to add any attachments?", vbYesNo)
If ans = vbYes Then
AttachFileName = Application.GetOpenFilename("Files (*.**)," & _
"*.**", 1, "Select File", "Open", True)
For a = LBound(AttachFileName) To UBound(AttachFileName)
FName = Dir(AttachFileName(a))
FileCopy AttachFileName(a), "N:\Customs\Customs_Docs\" & job & "\" & FName
Next a
Else
End If
strEmailAddr = [EMAIL="email.address@domain.com"]email.address@domain.com[/EMAIL]
objMailItem.Recipients.Add strEmailAddr
objMailItem.Body = ""
objMailItem.Subject = sbj & "-" & pri & "-" & job
Dim MyObj As Object, MySource As Object, file1 As Variant
file1 = Dir("N:\Customs\Customs_Docs\" & job & "\")
While (file1 <> "")
objMailItem.Attachments.Add "N:\Customs\Customs_Docs\" & job & "\" & file1
file1 = Dir
Wend
objMailItem.Display
Set objMailItem = Nothing
Set objOutl = Nothing
Application.ScreenUpdating = True
This code works, but every so often the users get the Run Time error mentioned in the thread title... I did some googling and I found this page on a similar error regarding to Word: You may receive the "Run-time error '-2147023174' (800706ba)" error message or the "Run-time error '462'" when you run Visual Basic code that uses Automation to control Word
It looks like it would relate to my error but replace word with outlook... It seems to say that a hidden global variable reference is created and that its not released between each runs of the code?
I tried to understand all that the link above said in relation to my code, but well I just don't understand it... Could one of you guru's fix my code above??
Thanks in advance