Hello,
I am doing a form which will be used on multiple device. ~50+
I am wondering if this is possible:
At a click of a button, I want following things to happen:
1. Save the file as excel format with a predefined file name. (remember location is multiple device, hence a macros to identify the computer name)
2. Open an outlook email (new email screed) with TO: prepopulate SUBJECT: File name with date Body: Prepopluate. ATTACHMENT: automatically attach the file.
3. let the user click the send button to send the file.
Currently i have separate buttons to save the file as pdf. and then email for users to email the file by manually attaching the file. THis wil be possible if the macros is able to determine the computer name to save the file in a folder.
I have the below seperate macros:
MACROS to save the file (I want save and email to operate with a clink of one button and use on 50+ users devices.)
SAVE MACROS:
EMAIL MACROS without attachment. (i want one with attachment)
I am doing a form which will be used on multiple device. ~50+
I am wondering if this is possible:
At a click of a button, I want following things to happen:
1. Save the file as excel format with a predefined file name. (remember location is multiple device, hence a macros to identify the computer name)
2. Open an outlook email (new email screed) with TO: prepopulate SUBJECT: File name with date Body: Prepopluate. ATTACHMENT: automatically attach the file.
3. let the user click the send button to send the file.
Currently i have separate buttons to save the file as pdf. and then email for users to email the file by manually attaching the file. THis wil be possible if the macros is able to determine the computer name to save the file in a folder.
I have the below seperate macros:
MACROS to save the file (I want save and email to operate with a clink of one button and use on 50+ users devices.)
SAVE MACROS:
Code:
Sub SavePDF1()
If WorksheetFunction.CountA( _
Worksheets("Sheet1").Range("C3")) < 1 Then
MsgBox "Workbook will not be saved unless" & vbCrLf & "All required fields have been filled in!", vbCritical, "Missing info"
Exit Sub
End If
If WorksheetFunction.CountA( _
Worksheets("Sheet1").Range("C4")) < 1 Then
MsgBox "Workbook will not be saved unless" & vbCrLf & "All required fields have been filled in!", vbCritical, "Missing info"
Exit Sub
End If
If WorksheetFunction.CountA( _
Worksheets("Sheet1").Range("C5")) < 1 Then
MsgBox "Workbook will not be saved unless" & vbCrLf & "All required fields have been filled in!", vbCritical, "Missing info"
Exit Sub
End If
If WorksheetFunction.CountA( _
Worksheets("Sheet1").Range("C6")) < 1 Then
MsgBox "Workbook will not be saved unless" & vbCrLf & "All required fields have been filled in!", vbCritical, "Missing info"
Exit Sub
End If
Dim Opendialog As Variant
Opendialog = Application.GetSaveAsFilename(Sheet1.[Sheet2!$CI$267].Value & Format(Date, "mmddyyyy"))
If Not Opendialog <> False Then MsgBox "File not saved.", vbCritical: Exit Sub
ActiveSheet.ExportAsFixedFormat Type:=xlType, Filename:=Opendialog _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
MsgBox "File Saved.", vbInformation
End Sub
EMAIL MACROS without attachment. (i want one with attachment)
Code:
Sub Mail_Workbook_Outlook()
Dim OlApp As Object
Dim OlMail As Object, Recip
Recip = [Sheet2!$CJ$264].Value
Set OlApp = CreateObject("Outlook.Application")
Set OlMail = OlApp.CreateItem(0)
On Error Resume Next
With OlMail
.To = Recip
.Subject = "HHA tool"
.Body = "Please find the attached HHA tool"
Select Case attachAWB
Case True
.attachments.Add ActiveWorkbook.FullName
End Select
If AttachmentPath <> "" Then
.attachments.Add (AttachmentPath)
End If
Select Case displayMail
Case True
.Display
Case True
.Send
Case Else
.Display
End Select
End With
On Error GoTo 0
Set OlMail = Nothing
Set OlApp = Nothing
End Sub
Last edited by a moderator: