Solved

Can I have the Excel Data Entry Form open on file open, then email worksheet when the form is closed?

Posted on 2014-10-08
4
188 Views
Last Modified: 2014-10-14
I would like to have the Excel produced Data Entry Form open when the file is open, then once the user has entered the data and clicked on close, have the worksheet emailed to a designated email address naming the attachment using the current user's logonID.
Can I edit the data entry form that Excel creates?
0
Comment
Question by:Michael Spellman
  • 2
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
ProfessorJimJam earned 500 total points
ID: 40368446
you can add below code into the "ThisWorkbook" Object

it will fire sending email, once user wants to close workbook.

try it in a backup copy.


Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim strDate As String
    ActiveSheet.Copy
    strDate = Format(Date, "dd-mm-yy") & " " & Format(Time, "h-mm-ss")
    ActiveWorkbook.SaveAs "Part of " & ThisWorkbook.Name _
        & " " & strDate & ".xlsx"
    ActiveWorkbook.SendMail "jamesbond@uk.gov", _
        "Subject_line"
    ActiveWorkbook.ChangeFileAccess xlReadOnly
    Kill ActiveWorkbook.FullName
    ActiveWorkbook.Close False
End Sub

Open in new window

0
 

Author Comment

by:Michael Spellman
ID: 40368761
This is the code that I used.  It opens the Data Entry Form.  (I'd like to get rid of the warning dialog box that appears - Excel cannot determine which row...etc).  Then when user closes the data entry form, it emails the active worksheet to me.

I would like to hide the workbook and just have the data entry form appear.  It would also be nice if I could edit the data entry form.  I suspect that I would have to switch to a userform, but dont know.  Is that correct?
ENS-AltForm.xlsm
0
 
LVL 26

Expert Comment

by:ProfessorJimJam
ID: 40368990
:)  by accident i opened the file and it sent two emails to one of the emails in the macro. so if you get those emails, please ignore them.  i will look at your file later today in detail and see what i could possible come up with.
0
 

Author Closing Comment

by:Michael Spellman
ID: 40379503
Thanks for the help.  If you get a chance to comment on the other aspects, let me know.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question