Access 2010 statement gives error message on Win 10 system

NoSmoke

Board Regular
Joined
Dec 1, 2012
Messages
114
I have an Access 2010 program that works fine under Win 7 but gives an error message when running under Win 10.

The problematic statement appears to be:

DoCmd.SendObject acSendNoObject, , , Me.EmailAddress2, , , Me.EmailSubject, Me.EmailContent, False

An message appears stating an error has occurred and the program must close.

The associated program was written under Win 7 and run under Win 10 with the Access 2010 run-time app. In both cases, the email program the statement references is Mozilla Thunderbird.

I don't even know where to start looking for a solution and would appreciate any suggestions as I am attempting to migrate to Win 10 now that MS has announced Win 7 will no longer be supported after Jan 2020.

Thank you in advance...
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
> DoCmd.SendObject acSendNoObject, , , Me.EmailAddress2, , , Me.EmailSubject, Me.EmailContent, False

so that's in a module ?
open the modele that's in and from the menu select Tools / References
look and see if one of the checkboxes says "missing"
 
Upvote 0
Not sure how you managed that.
A quick google states that Thunderbird does not expose it's object properties/methods.?

One alternative is
Code:
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Sub test()
    strPath = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"
    strTo = "emailaddress" 'change to suit
    strSubj = "Whatever subject" 'change to suit
    strBody = "Text in body of email" 'change to suit
    strAtt = "G:\documents\partituur.pdf" 'to add attachment

    strShell = strPath & " -compose """ & "to='" & strTo & "'," & _
        "subject='" & strSubj & "'," & "body='" & strBody & "'," & _
        "attachment=file:///'" & strAtt & "'" & """"
    
    Call Shell(strShell, vbNormalFocus)
End Sub

Also try https://www.google.com/search?q=sen....69i57j0l3.16209j0j7&sourceid=chrome&ie=UTF-8
HTH</code>
 
Upvote 0
> DoCmd.SendObject acSendNoObject, , , Me.EmailAddress2, , , Me.EmailSubject, Me.EmailContent, False

so that's in a module ?
open the modele that's in and from the menu select Tools / References
look and see if one of the checkboxes says "missing"

Thanks James but I can't do that (I think) because I only have the runtime version of Access on my Win 10 installation.
 
Upvote 0
Not sure how you managed that.

I'm not sure (actually I don't know) why it works (on my Win 7 install) either. IIRC, it was something I copied, maybe from this forum, a number of years ago and the details are fuzzy now.

A quick google states that Thunderbird does not expose it's object properties/methods.?

One alternative is
Code:
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Sub test()
    strPath = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"
    strTo = "emailaddress" 'change to suit
    strSubj = "Whatever subject" 'change to suit
    strBody = "Text in body of email" 'change to suit
    strAtt = "G:\documents\partituur.pdf" 'to add attachment

    strShell = strPath & " -compose """ & "to='" & strTo & "'," & _
        "subject='" & strSubj & "'," & "body='" & strBody & "'," & _
        "attachment=file:///'" & strAtt & "'" & """"
    
    Call Shell(strShell, vbNormalFocus)
End Sub

Also try https://www.google.com/search?q=sen....69i57j0l3.16209j0j7&sourceid=chrome&ie=UTF-8
HTH</code>

Thanks - that looks a lot more plausible. I will give it a try. :)
 
Upvote 0
Hey gasman, tried your suggested code and it triggered a Thunderbird write screen but it was blank with nothing filled in for From, To, Subject or Body (I deleted the strAtt statement as I had no need for an attachment). What I want to do is have Access automatically fill in the data and send the email (which is what my original DoCmd statement performed) all without manual intervention.

If you could make the code do that, I would be most appreciative as, as I mentioned earlier, the DoCmd statement causes a runtime error in Win 10/Access 2010 run-time and I have no idea how to fix it myself.

Thanks again in advance....
 
Upvote 0
All that code is doing is using the cmd line to send the email. The code was copied and pasted as is, so I would have expected it to work.?
You could Debug.Print strShell and paste that into the cmd line and also check the syntax.?
I would also try that hard coded manually to see what happens. I do not have Thunderbird, so have no way of testing.

Alternatively try CDO ?

https://www.rondebruin.nl/win/s1/cdo.htm
 
Upvote 0
DoCmd.SendObject acSendNoObject, , , Me.EmailAddress2, , , Me.EmailSubject, Me.EmailContent, False

Presumably this depends on Thunderbird being the default mail application. Is that the case?
 
Upvote 0
Hey, following one of the links you suggested, found similar Excel VBA code to yours and, with a small change to create a program pause, it works.

Code:
 Dim thund As String
    Dim email As String
    Dim cc As String
    Dim bcc As String
    Dim subj As String
    Dim body As String

    email = "laforbes@telus.net"
    cc = "test@test.com"
    bcc = "test@test.com"
    subj = "Testing"
    body = "Testing"

    thund = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe " & _
            "-compose " & """" & _
            "to='" & email & "'," & _
            "cc='" & cc & "'," & _
            "bcc='" & bcc & "'," & _
            "subject='" & subj & "'," & _
            "body='" & body & "'" & """"

    Call Shell(thund, vbNormalFocus)
    
    For i = 1 To 100000000 'Pause b/f SendKeys for it to work properly
    Next
    
    SendKeys "^{ENTER}", True

The SendKeys is necessary to prompt Thunderbird to send the email. The long loop is a pause which is needed before the SendKeys is executed as nothing happens otherwise (the Excel version used a Wait function which Access DB apparently does not recognize so I used a bit of kludge code to simulate it - maybe there is a more elegant method(?)).

Thanks for pointing me in the right direction!
 
Last edited:
Upvote 0
Hi, you can pause this way:
Code:
Option Compare Database
Option Explicit
Public Declare PtrSafe Sub sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As LongPtr)
'For 32 Bit Systems: Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds as Long)

Sub testit()
MsgBox "testing"
sleep 5000 '//5 seconds
MsgBox "testing"
End Sub

The only thing is that the declaration of the sleep function must be at the top before any other subs or functions in the module.
 
Upvote 0

Forum statistics

Threads
1,215,035
Messages
6,122,785
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top