SOLVED

Form with Macro loosing Data

Copper Contributor

Hi, I have produced a form in Excel, It has active x button that runs a macro to send the form to the next relevant person. The trouble im having is the data being inserted before the form is sent is being lost once it is attached to the email via the macro, the macro im using is as follows-(Email removed for security).

Sub SendToConfig()
Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
'Let us create the email message aL61-2004nd display it
'Make sure to change the parameters below
With OutlookMail

.To = ""
.Subject = Range("C5") & " establishment for processing"
.HTMLBody = "Hello, please see attached product establishment for processing"
.Attachments.Add ActiveWorkbook.FullName
.Display
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub

 

Please advise why i am loosing the data input on the form!

3 Replies
best response confirmed by Hans Vogelaar (MVP)
Solution

@LifeBoatMat 

Maybe you can find some information here

Mail from Excel with SendMail (Windows)

Standard Disclaimer: These are links to non-Microsoft websites.

A wonderful site in terms of emailing (not only) :)

 

Hope I was able to help you with this info.

 

NikolinoDE

I know I don't know anything (Socrates)

@NikolinoDE thank you for your help, used the code here : https://www.rondebruin.nl/win/s1/outlook/amail1.htm

It now works a treat and do not loose the data, turns out it needs to save a copy of an active workbook first so this code does a temporary save and deletes it after.

I am pleased that you were able to come to a solution and I also wish you every success with your projects with Excel :).
1 best response

Accepted Solutions
best response confirmed by Hans Vogelaar (MVP)
Solution

@LifeBoatMat 

Maybe you can find some information here

Mail from Excel with SendMail (Windows)

Standard Disclaimer: These are links to non-Microsoft websites.

A wonderful site in terms of emailing (not only) :)

 

Hope I was able to help you with this info.

 

NikolinoDE

I know I don't know anything (Socrates)

View solution in original post