Switch from XP to Vista now Command Button not working.

Dzine2009

Registered User.
Local time
Today, 07:33
Joined
Aug 17, 2009
Messages
27
I have the following code working on my XP machine.

Code:
Private Sub Command25_Click()
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
    .BodyFormat = olFormatRichText
    .To = Nz(DLookup("Contact_Information_Email", "Inspection", "[requests_InspectionID]=" & Me!requests_InspectionID)) & ";" & Nz(DLookup("Agent_Email", "Inspection", "[requests_InspectionID]=" & Me!requests_InspectionID)) & ";" & Nz(DLookup("Listing_Agent_Email", "Inspection", "[requests_InspectionID]=" & Me!requests_InspectionID))
    .Subject = "Your inspection has been scheduled."
    .Body = "Greetings " & Format(DLookup("Contact_Information_FirstName", "Inspection", "[requests_InspectionID]=" & Chr(34) & Me!requests_InspectionID & Chr(34)), " ") & " " & Format(DLookup("Contact_Information_LastName", "Inspection", "[requests_InspectionID]=" & Chr(34) & Me!requests_InspectionID & Chr(34)), "") & " your inspection has been scheduled for " & Format(DLookup("InspectionDate", "Inspection", "[InspectionID]=" & Me!Inspection_InspectionID), "mmmm d, yyyy") & " at " & Format(DLookup("InspectionTime", "Inspection", "[InspectionID]=" & Me!Inspection_InspectionID), " hh:mm AMPM ") & " at the following address; " & Nz(DLookup("SiteAddress", "Inspection", "[SiteAddress]=" & Chr(34) & Me!SiteAddress & Chr(34)), "") & ". If you have any questions or concerns please feel free to contact us." & vbCrLf & vbCrLf & "Thank you," & vbCrLf & "Kurt Nelson" & vbCrLf & "Winding River Home Inspection Services LLC." & vbCrLf & "970-222-2104 or 303-774-1104"

    .Display
End With
'MsgBox MailOutLook.Body
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out
Error_out:
End Sub

When I changed to Vista the code stopped working. I ran the debug and have not received any errors... Im totally at a loss here.
 
Notice you create two instances of Outlook each time this code runs, and two new mail items. I'd sort that out and see if it makes a difference.
 
Took that out with the same responce NOTHING. Bah Humbug Vista...
 
Took that out with the same responce NOTHING. Bah Humbug Vista...

Took those out but did you go into Task Manager and verify that no Outlook was running before trying the code again?
 
Hi

probably sounds stupid but have you

Renamed the button?
Checked that the code is still linked to the button? If you highlight the button in design view, does the OnClick event show text? If you click the browse part of the properties, does it open your vba editor at your code?

Nidge
 
Oh and, I will assume you have added outlook to the vista install?

Nidge
 
Sorry for the lateness in reply. I was not getting the enable macro security warning so that was the issue. Enabled macros and everything worked fine, but it did boggle my mind completely for about a week. Thanks so much for all your ideas!

One more question, want to add more text to the email but there seems to be some sort of character limit or maybe I dont know how to format correctly. Im using rich text format for the email. I just wanted to add more straight text but it stops when VB editor gets to the end of the line im writing in. Is there a way around this? or is there really a character limit for rich text?
 

Users who are viewing this thread

Back
Top Bottom