+ Reply to Thread
Results 1 to 3 of 3

VBA - Send Excelsheet in another format

  1. #1
    Registered User
    Join Date
    11-10-2016
    Location
    Hamburg, Germany
    MS-Off Ver
    2013
    Posts
    1

    VBA - Send Excelsheet in another format

    Hi guys,

    it's my first try in this community and hope someone can help me with my vba issue. I already modified a vba code I found in the internet. This code already send the document in .xlsm and save it into the correct folder.

    My question, is it possible to modify it in the way that the file still will be saved as .xlsm and send a copy as a .xls? Does not make sense to send the file with all macro buttons working to my colleagues :-D Otherwise they would click the buttons and I will get many new emails

    Thanks in advance

    The code:
    Sub Mail_Workbook()
    Dim wb1 As Workbook
    Dim wb2 As Workbook
    Dim TempFilePath As String
    Dim TempFileName As String
    Dim FileExtStr As String
    Dim OutApp As Object
    Dim OutMail As Object

    With Application
    .ScreenUpdating = False
    .EnableEvents = False
    End With

    Set wb1 = ActiveWorkbook

    'Make a copy of the file/Open it/Edit it/Mail it/Delete it
    'If you want to change the file name then change only TempFileName
    TempFilePath = "Pfad zum Zielordner"
    TempFileName = "filename " & Format(Now() - 1, "dd-mmm-yy")
    'Configure yesterday
    FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1)))

    wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr
    Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr)


    '**************Add code to edit the file here********************
    'Insert a text and Date in cell A1 of the first sheet in the workbook.
    'Other things you can think of are for example, delete a whole sheet or a range.
    wb2.Worksheets(1).Range("A1").Value = "Copy created on " & Format(Date, "dd-mmm-yyyy")

    'Save the file after we changed it with the code above
    wb2.Save


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

    On Error Resume Next
    With OutMail
    .to = ThisWorkbook.Sheets("QUELLEVERSAND").Range("O1").Value
    .CC = ""
    .BCC = ""
    .Subject = "TEXT - " & Format(Now() - 1, "dd-mmm-yy")
    .Body = "Dear colleagues," & vbCrLf & "pls find attached our latest ..." & vbCrLf & " _
    Feel free to contact me if there are any questions." & vbCrLf & "Kindly regards" & vbCrLf & "ME"
    .Attachments.Add wb2.FullName
    'You can add other files also like this
    '.Attachments.Add ("C:\test.txt")
    .Send 'or use .Display
    End With
    On Error GoTo 0
    wb2.Close savechanges:=False


    Set OutMail = Nothing
    Set OutApp = Nothing

    With Application
    .ScreenUpdating = True
    .EnableEvents = True
    End With
    End Sub

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: VBA - Send Excelsheet in another format

    Save the file as XLSM

    Save the file as XLS

    Open XLS Fle

    Send XLS File.

    Close XLS File
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,540

    Re: VBA - Send Excelsheet in another format

    Re: send a copy as a .xls? Does not make sense to send the file with all macro buttons working
    Macros work in .xls type files also.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Format Excelsheet with VBA
    By karlik in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-07-2015, 07:06 AM
  2. Send an excelsheet using vba
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-05-2013, 10:17 AM
  3. Macro to Format/Insert/Send
    By JosueDG in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2012, 12:25 AM
  4. Fetch data from Access table in Excelsheet in specific format
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-17-2012, 05:31 AM
  5. Send outlook task from Excel sheet (including the excelsheet)
    By Jop_4444 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-08-2012, 05:26 PM
  6. Send excelsheet in the body of an email using vba
    By Nancy123 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-30-2010, 07:06 AM
  7. Send email containing link in XML-format
    By Claus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2009, 08:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1