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
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

695 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