Getting the directory of the file and send as attachment in outlook
<p>I have this code that gets the filenames on the selected directories.</p>

<pre><code>Sub browsefile()
Dim file As Variant
Dim i As Integer
Dim lRow As Long
Set main = ThisWorkbook.Sheets("Main")

file = Application.GetOpenFilename("All Files, *.*", , "Select File", , True)

For i = 1 To UBound(file)
    lRow = Cells(Rows.Count, 15).End(xlUp).Row
    lRow = lRow + 1
    ThisWorkbook.Sheets("Main").Range("O" &amp; lRow).Value = GetFileName(CStr(file(i)))
Next i
End Sub

Function GetFileName(filespec As String)
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    GetFileName = fso.GetFileName(filespec)
End Function
</code></pre>

<p>Once I've selected the files, I have to put it in Column O. I have tried using <code>.FullName</code> but is not applicable in this area or maybe I've just misused it. Then later this will be send as attached file in an email in outlook. </p>

<p>By the way, I've got some of its code <a href="http://www.ozgrid.com/forum/showthread.php?t=72305" rel="nofollow">here</a>. </p>

<p>Any help?</p>