PDA

View Full Version : VBA Code help



depa
06-30-2010, 06:27 AM
Hi

I have a Macro where If i click a Link in access it should run the macro and attach a .txt file to the email. But I am getting the .txt file as .xls which I am unable to open. I can see the data is if i right click and open in word. How can I make it the code to attach .txt instead of .xls. Please advice ASAP.

CreganTur
06-30-2010, 08:31 AM
Welcome to the forum.

We can't help you without seeing the code. Be sure you wrap the code with VBA tags (click teh green VBA button). This will make the code readable and format it.

depa
06-30-2010, 10:10 AM
Here is the code

Function mcrEmailPaymentsXL()
On Error GoTo mcrEmail_Err
Dim txtObjectName As String
Dim txtTO As String
Dim txtSubject As String
Dim txtMessage As String
txtObjectName = "Payments"
txtTO = "xyz@abc.com "
txtSubject = "Payments for " & Date
txtMessage = "Attached are today's payments."
DoCmd.SendObject acSendReport, txtObjectName, acFormatXL, txtTO, "xyz@abc.com", "", txtSubject, txtMessage, False, ""
mcrEmail_Exit:
Exit Function

OBP
07-01-2010, 05:59 AM
You have used the output format acFormatXL, you should have used
acFormatRTF or
acFormatTXT