I have a macro in outlook which saves attachments from new emails based on certain criteria.
I also have a macro in excel which edits these files once they have been saved.
How can I call the outlook macro (GetAttachments) from my excel macro?
I have a macro in outlook which saves attachments from new emails based on certain criteria.
I also have a macro in excel which edits these files once they have been saved.
How can I call the outlook macro (GetAttachments) from my excel macro?
According to this link:
http://help.lockergnome.com/office/C...ict877683.html
you use:
[VBA] Call Outlook.Application.TestMacro("test@test.com", "Test","C:\test.xls") [/VBA]
A little more digging suggested that you needed to open an Outlook.Application item first:
[VBA]Function OpenOL(Optional ProfileName) As Outlook.Application
Dim objOL As Application Outlook.Application
On Error Resume Next
Set objOL = GetObject(, "Outlook.Application")
If objOL Is Nothing Then
Set objOL = CreateObject("Outlook.Application")
objOL.Session.Logon ProfileName, , False, True
End If
Set OpenOL = objOL
Call OpenOL.TestMacro
Set objOL = Nothing
End Function
[/VBA]
However, when I run it I receive an error that Outlook.Application is an unknown object. I tried commenting out the offending words "Outlook.Application", but it still doesn't work (it does run without error, however).
HTH, a little, at least.
I'd love some help on this too. I'm trying to do something very similar to this. and having the same type of error.
Regards,
JP
Read the FAQ
Getting free help on the web
My website
Please use [vba][/vba] tags when posting code
Hello Smithani,
Can you able to get through the above macro, as am looking for the same macro where in the criteria's are given in excel and wanted to save the attachments in specified path.
Request you to share the macro which you could have created, Appreciate your response.
thanks in advance
Regards,
guru
Outlook would be an unknown object unless you tell Excel what Outlook is. You can do this by setting a reference to the Outlook object library in the Excel VBA Editor Tools > References. Or you could use late binding to Excel and change the references in the Function e.g. as follows. As for the running without errors, you have the option set On Error Resume Next.
As for the rest, I haven't tested the code.Function OpenOL(Optional ProfileName) As Object Dim objOL As Object On Error Resume Next Set objOL = GetObject(, "Outlook.Application") If objOL Is Nothing Then Set objOL = CreateObject("Outlook.Application") objOL.Session.Logon ProfileName, , False, True End If Set OpenOL = objOL Call OpenOL.TestMacro Set objOL = Nothing End Function
Graham Mayor - MS MVP (Word) 2002-2019
Visit my web site for more programming tips and ready made processes
http://www.gmayor.com
Have you checked the fuse for the wipers?If the fuse is good then check the wiring from the pump back.