E Mail from Access 2007 on Windows 8.1

tomv

Registered User.
Local time
Today, 12:31
Joined
Dec 3, 2013
Messages
12
I have a MS Access 2007 database running on 6 machines with windows 7 - no issues.
The application sends e mails with and without attachments via MS Outlook.
I have installed the application on a Windows 8.1 machine and get error when trying to send e mails from within the application.


Error -2147024156 (Automation Error) in procedure Command28_Click of VBA Document Form_frmGen


MS Outlook is set as the default mail programme.
Any suggestions?
 
Please post code for Command 28 click.

And if you know how loop through the code and identify the row where the error occurred.
 
Thanks for your interest Uncle Gizmo.
The code follows. Although I used this case to seek help, the problem exists in all E Mail procedures and then only on the Windows 8.1 machine. All others, Windows 7, running as expected.

Code begins:*****************************
Private Sub Command28_Click()
Dim EmailAddress As String
Dim OMail As Object
Dim Templatepath As String
Dim OLook As Object

On Error GoTo Command28_Click_Error

EmailAddress = Me.Email
Templatepath = CurrentProject.Path & "\Atlas Outlook Template.oft"

Set OLook = CreateObject("Outlook.Application")
Set OMail = OLook.CreateItemFromTemplate(Templatepath)
With OMail

.To = Me.Email
.Body = "Phone Message received for: " & Me.StaffName & vbCrLf & vbCrLf & _
"Date: " & Me.ReceivedDate & vbCrLf & _
"Time: " & Me.ReceivedTime & vbCrLf & _
"From: " & Me.From & vbCrLf & _
"Phone: " & Me.Phone & vbCrLf & _
"Cell: " & Me.Cell & vbCrLf & _
"E Mail: " & Me.ClientEmail & vbCrLf & vbCrLf & _
"Message: " & Me.Message & vbCrLf & _
""
.Subject = "Phone Message"
.Display
End With
Set OMail = Nothing
Set OLook = Nothing
On Error GoTo 0
Exit Sub
Command28_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Command28_Click of VBA Document Form_frmGenPhoneMessage"
End Sub
Code ends*****************************
 
I don't think this is it but it's worth a try I would change the current project path to a hard coded path you know exists.
 
The only other thing I would check is your references; make sure they haven't changed between the different versions of windows.
 
This is worth checking. I am using an ACCDE on the windows 8 machine, same as all the others. I did not think the references would change in compiled ACCDE file, but I will copy the ACCDB on the windows 8 machine and check the references. I will post here with the outcome.
 
Unfortunately this was not a references issue. All the right references are checked. With regard to the Current.ProjectPath, this would not have been an option since the application is used by six machines making it difficult to use a fixed path, but I tested it anyway. This did not resolve the issue.

I read somewhere in the last couple of weeks while dealing with this problem that it could be due to Late or Early Binding of the compiled database. I just don't know what this means, but my understanding of the article was that Windows 8 handles Office 2007 "too fast". I wish I had kept a link to the article, but it really did not seem important at the time. Does the "Binding" mean anything to anyone?
 
I read somewhere in the last couple of weeks while dealing with this problem that it could be due to Late or Early Binding

Microsoft Access VBA – object variables
Early binding versus late binding

In your case I think this means you need to set a reference to Outlook:-

Microsoft Outlook 12.0 Object Library (The 12.0 may be a different number for different versions)

and change your code to something like:-

Code:
Dim EmailAddress As String
Dim OMail As Object
Dim Templatepath As String
Dim OLook As Outlook.Application

EmailAddress = ""
Templatepath = CurrentProject.Path & "\Atlas Outlook Template.oft"

Set OLook = New Outlook.Application
Set OMail = OLook.CreateItemFromTemplate(Templatepath)
 
The reference to Outlook was already set.
I changed the code as suggested.

I went further and removed the template (sent the message from the standard Outlook template)

None of this seems to make any difference to the Win 8.1 machine - curious thing this progress from Windows 7 which was happy and kept me happy along with it.

Thanks for all your help thus far. I don't know what else to ask or try.
 
Uncle Gizmo must be having one of those days ... :D

For LATE binding, remove the reference to Outlook and:

Code:
Dim EmailAddress As String 
Dim OMail As Object 
Dim Templatepath As String 
Dim OLook As [COLOR=Red]Object[/COLOR]  
EmailAddress = "" 
Templatepath = CurrentProject.Path & "\Atlas Outlook Template.oft"  
Set OLook = [COLOR=Red]CreateObject("Outlook.Application")[/COLOR] 
Set OMail = OLook.CreateItemFromTemplate(Templatepath)
 
Hmm butthat is what you DID have.

Now, which line gives you the error? Remove the On Error line to see that
 
With or without the Error Line or Error Handler, I do not get the option to Debug or see where the problem lies. Just the error message I posted at the start of the post.
 
Thanks Spikepl.
I did as advised.
Removing the reference to Outlook causes the button to do nothing. No error message, no action, on Win 8.1.

Send the mail without problems on Win 7.
I re-checked the reference for all the other mail procedures in the application, I could not compile without it, but I would have been willing to change them all if this presented a solution.

I might be looking for Windows 95 soon. That one was not clever enough to be fussy. :)
I take your point about Win 7 being what I had. We are about to replace another 6 laptops in the office and, no doubt, they will come with Win 8.1.
 
With or without the Error Line or Error Handler, I do not get the option to Debug or see where the problem lies. Just the error message I posted at the start of the post.
To be absolutely clear, this line:
Code:
On Error GoTo Command28_Click_Error
should be replaced with this line:
Code:
[COLOR="Red"]' [/COLOR]On Error GoTo Command28_Click_Error
Now re-run your code and tell us which line throws the error message.
 
Done.

The code stops on this line:
Set OLook = CreateObject("Outlook.Application")
 
To test:

1. Open Outlook, make sure it's running and keep it open
2. Change the CreateObject() code line to this:
Code:
Set OLook = GetObject(, "Outlook.Application")
3. Debug > Compile and re-run the code

Tell us the result.
 
Thanks.
Done.
Win 8.1 Error Message:
Runtime Error 429. Activex Component cannot create object.

Win 7: Working as expected.
 
I am busy with a fresh installation of MS Office. Also trying the same on two other Win 8.1 machines.

Taking some time to install and will post back here.
(Along with the service packs and other updates before I test)
 

Users who are viewing this thread

Back
Top Bottom