last day (15 days later) » 

11:19 AM
0
A: Why does the VBA outlook object don't work?

FaneDuruTry this code, please: On Error Resume Next Set OutApp = CreateObject("Outlook.Application") Set Outmail = Outapp.Createitem(0) If Err <> 0 Then Err.Clear: On Error GoTo 0 MsgBox "No Outlook Application installed, or not configured": Exit Sub End If On E...

 
I added this, but then the macro fails again at the row Set Outmail = Outapp.Createitem(0).
 
This means that Outlook is installed! It is not configured... I will change it to solve that.
 
Is there also a possiblity to look first if the app is installed if not then get a msgbox? We are working with 2 options one normal pc then there is outlook and Remote and then there is no outlook app.
 
@Karel Jansen: Yes, we must put both lines to be checked. Iwill adapt the code...
 
@fanuDuru, could you help me with that please, i'm already hours working on it but i couldn't figure it out haha!
 
11:19 AM
@Karel Jansen: With pleasure, but I need to know what does not work as you like. Would you like to have different messages for each case? Or, what?
 
i got a error At the set outmail = outapp.createitem(0). It says can't create message because datasource isn't found. On the normal pc the code is working fine. Currently i have attachted your first piece of code on the set outapp. I hope this is clear enough haha!
 
This is not possible...
Did you use my updated code? Please, refresh the page...
 
11:42 AM
Thanks! This works indeed better
Can i also send the code in here?
 
Of course. But, take care to select it after pasting and press Ctrl + K. In this way it will be nicely formatted as code...
 
Sub Mail_workbook_Outlook_1()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim bodystr As String

 On Error Resume Next
    Set OutApp = CreateObject("Outlook.Application")
    If err <> 0 Then
        err.Clear: On Error GoTo 0
        MsgBox "No installed Outkook": Exit Sub
    End If
    On Error GoTo 0
    Set OutMail = OutApp.CreateItem(0)

    bodystr = "Test"

    ActiveWorkbook.Save

    On Error Resume Next

    With OutMail
        .To = Worksheets("Test").Range("D25")
        .CC = Worksheets("Test").Range("D26")
 
This is not the updated code...
 
Could you provide me the whole code sorry. I have understanding of basic VBA but this is very hard for me!
 
On Error Resume Next
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    If Err <> 0 Then
        Err.Clear: On Error GoTo 0
        MsgBox "No Outkook application installed or configured...": Exit Sub
    End If
 On Error GoTo 0f
 
11:52 AM
Thank you so much! I'm learning and learning VBA and i really love it but sometimes it is hard haha!
 
If you wont a specific message for each case, it is also possible...
So, does it work as you need?
 
Yes thank you so much! You are a hero haha :D
If i got any quetsions in the future is it possible to send you a message?
Can i also give you a + somewhere?
 
In such cases, we vote up (if enough notoriety - >= 15) the code and more important is to tick the check box to the code left size, in order to make it the accepted answer. When somebody else will kook for something similar, he will know that the answer has been accepted...
 
12:37 PM
Still alive? :)
 
 
1 hour later…
2:04 PM
Yes haha, i did it i think!
 

last day (15 days later) »