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