Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 623
- Office Version
- 365
- 2010
- Platform
- Windows
This code seems to create a book of the first page of the workbook. I tried the following code:
does not display the file path. When I run this code, it asks to "Save 'Book #' with references to unsaved documents?" I don't even know where that is located. I also need to save this file with a specific name. "WO Report" & Format(now, "mm.dd.yyyy"). Thank you
VBA Code:
Sub Email()
Dim OutApp As Object
Dim OutMail As Object
Dim Filename As String
Dim wbAnswer, EmilAnswer As Integer
Application.ScreenUpdating = False
Worksheets("WO Report Summary 4.0").Copy
Set wb = ActiveWorkbook
Filename = wb.Worksheets(1).Name
On Error Resume Next
Kill Filename
On Error GoTo 0
wb.SaveAs Filename:="C:\" & Filename
EmailAnswer = MsgBox("Do you want to email this file?", vbYesNo + vbDefaultButton1 + vbQuestion, "Email: " & sFileName)
If EmailAnswer = vbYes Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
' .To =
' .CC =
' .Subject =
.Attachments.Add [B]I am not sure what to put here. I would assume the file path would go here but I don't see that here in the code. [/B]
.Display
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
Else
Exit Sub
End If
wbAnswer = MsgBox("Are you sure you want to close this workbook and Excel?", vbYesNo + vbDefaultButton1 + vbQuestion, "WORKBOOK: " & ActiveWorkbook.Name)
If wbAnswer = vbYes Then
ActiveWorkbook.Save
Application.Quit
Else
Exit Sub
End If
End Sub
VBA Code:
wb.SaveAs Filename:="C:\" & Filename