Save file to Specific Directory - then EMAIL

L

LRay67

I am not sure what I am doing wrong with the code below. I need to
specifically state in the code what network directory (N:) the file is to be
saved to. The below for saving to specific directory is not working. Please
Help. Thanks

Private Sub CommandButton1_Click()
'Working in 2000-2010
'This example send the last saved version of the Activeworkbook
Dim MyPath As String
Dim fname As Variant
Dim Wb As Workbook
Set Wb = ActiveWorkbook
MyPath = "\\N:\Business Process Engineering\PROJECTS\TEST"
'MyPath = "\\N:\Personnel\Employee Exit Forms - Initial"
fname = Application.GetSaveAsFilename(TextBox7.Value & " - Exit Form " &
Format$(TextBox1.Value, "mmddyyyy"), _
fileFilter:="Excel Files (*.xls), *.xls")
If fname <> False Then
Wb.SaveAs fname
'Wb.Close False
Set Wb = Nothing
Else
Set Wb = Nothing
End If
' ActiveWorkbook.Save
Dim OutApp As Object
Dim OutMail As Object

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Employee Exit Form - Complete within 3 Business Days of
Receipt"
.Attachments.Add ActiveWorkbook.FullName
'You can add other files also like this
'.Attachments.Add '("C:\test.txt")
.Display 'or use .Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
P

Paul

If you recorded this as a macro you would not get the \\ at the start of the
folder list - could be this is the problem
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top