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
183 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 25

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 25

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
A high-level exploration of how our ever-increasing access to information has changed the way we do our jobs.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

705 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now