can I send a file by email versus to a local desktop?

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
In my code below I have this line of code
Case "TD"
strfilename = "\\Tomsblackibm\TomsProposals\" & strfilename
I would like to send this file by email if possible instead of to his computer. The user recently went from a desktop "in the office" to a laptop "all over the place".

Here is my code
Code:
Sub Save_and_SaveSalesman()


Dim strPath As String, strPath2 As String, CurrPath As String
    
    Dim WB1 As Workbook
    Dim WB2 As Workbook
        
    Set WB1 = ActiveWorkbook
    
    'First thing, save my work
    WB1.Save
    
    CurrPath = WB1.Path
    
    'ASSUMING THAT C6 and O3 are BOTH in WB1
    'move this line HERE: only do this once, and concatenate in the Select..Case later
    'doing thsi inside the Select..Case pulls values from WB2, which might cause errors...
    strfilename = Range("C6").Value & Range("O3").Value & ".xls"
    
    strPath = "C:\Documents and Settings\Owner\My Documents\Completed Proposals\"
    
    strPath2 = "C:\Documents and Settings\Owner\My Documents\Surface Systems\"
    
    On Error Resume Next
    
    'I then want to save my file as "Proposal" and the number in Cell O3
    WB1.SaveAs Filename:=strPath & strfilename
    
    On Error GoTo 0
    
    'I call this workbook "new_file"
    'as long as you use the WB1 object, you should not need to store the name... - PES
'    new_file = wb1.Name
    
    'you should never need to select anything... - PES
'    Range("F2").Select
    
    'I want to open "Proposal for XL" so I can make a 2nd copy to the salesmans computer
    Set WB2 = Workbooks.Open(Filename:=strPath2 & "Proposal for XL.xls")
    
    'I have to save the "new_file"
    'WHY??? you did this above - PES
'    Workbooks(new_file).Save
    
    'Workbooks(new_file).Close
    'Here is where i need to choose the computer for it to go to. As well as give the file a name that the salesman recognizes. C6 is customer name and O3 is the proposal number
    'Select Case WB2.Sheets("FRONT").Range("C2").Value
    Select Case WB1.Sheets("FRONT").Range("C2").Value
        Case "MD"
            strfilename = "\\MIKESRGATEWAY\MikesProposals\" & strfilename
            
        Case "TD"
            strfilename = "\\Tomsblackibm\TomsProposals\" & strfilename
            
        Case "DJ"
            strfilename = "\\DAVEJONES\DavesProposals\" & strfilename
            
        Case "CP"
            strfilename = "\\Chuckscomputer\daily\" & strfilename
            
    End Select
    
    WB1.SaveCopyAs Filename:=strfilename
    
    WB1.ActiveSheet.Shapes("Button 53").Visible = False
    
    ChDir CurrPath
    
    Application.ScreenUpdating = True
    
    WB1.Close
End Sub



Thank You,
Michael
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
yeah i know about this site. I just thought there was a line of code to do this??? I was trying to avoid adding a lot more code to my exsisting string of code.

Michael
 
Upvote 0
Norie,
Will it open AOL and send it through AOL? The person with the code on their computer uses AOL for email. So It would have to open AOL, then send the file as an attachment etc. etc.

Michael
 
Upvote 0
Michael

I don't honestly know how SendMail would deal with AOL mail, which I assume is webmail.

It's meant to work with whatever the default mail client is.
 
Upvote 0
Michael

Do you really need to use AOL?

Does it matter as long as the email get's sent.
 
Upvote 0
NOt really i guess. But I have to setup POP or IMAP and all these things that I just am not too familiar with..
 
Upvote 0
Michael

Are you sure you need to do that?

Have you tried SendMail?
 
Upvote 0

Forum statistics

Threads
1,223,521
Messages
6,172,812
Members
452,481
Latest member
Najwan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top