+ Reply to Thread
Results 1 to 5 of 5

Keep Macro in tact Excel to Outlook, the Outook reply back to Excel

Hybrid View

  1. #1
    Registered User
    Join Date
    03-21-2015
    Location
    united state
    MS-Off Ver
    2010
    Posts
    4

    Keep Macro in tact Excel to Outlook, the Outook reply back to Excel

    I have created a form in Excel and the code contains 2 send buttons. Once the form is completed it lauches outlook with prefilled information. The first send works great. When the receipent reply back with the information, the 2nd send button in the form is not launching the new outlook window. I am very new to using code and would appreciate any help. I know the issues is the macro is not staying attached to the excel spreadsheet so when the file is sent back there is not code for Send button 2. I can' figure out how to keep the macro with the sheet so it remains in tact.

    Any help is much appreciated.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,818

    Re: Keep Macro in tact Excel to Outlook, the Outook reply back to Excel

    Please attach the Excel file you are using. If you cannot provide your file, post code in a reply using CODE tags. Include all the code.

    To use CODE tags:

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-21-2015
    Location
    united state
    MS-Off Ver
    2010
    Posts
    4

    Re: Keep Macro in tact Excel to Outlook, the Outook reply back to Excel

    Private Sub CSSEND_Click()
    Last edited by Jackieb302; 03-21-2015 at 06:27 PM.

  4. #4
    Registered User
    Join Date
    03-21-2015
    Location
    united state
    MS-Off Ver
    2010
    Posts
    4

    Re: Keep Macro in tact Excel to Outlook, the Outook reply back to Excel

    Private Sub CSSEND_Click()
              
     Dim FileExtStr As String
        Dim FileFormatNum As Long
        Dim Sourcewb As Workbook
        Dim Destwb As Workbook
        Dim TempFilePath As String
        Dim TempFileName As String
        Dim OutApp As Object
        Dim OutMail As Object
    
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
        End With
    
        Set Sourcewb = ActiveWorkbook
    
         ActiveSheet.Copy
        Set Destwb = ActiveWorkbook
    
             With Destwb
            If Val(Application.Version) < 12 Then
                'You use Excel 97-2003
                FileExtStr = ".xls": FileFormatNum = -4143
            Else
                'You use Excel 2007-2013
                Select Case Sourcewb.FileFormat
                Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
                Case 52:
                    If .HasVBProject Then
                        FileExtStr = ".xlsm": FileFormatNum = 52
                    Else
                        FileExtStr = ".xlsx": FileFormatNum = 51
                    End If
                Case 56: FileExtStr = ".xls": FileFormatNum = 56
                Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
                End Select
            End If
        End With
    
      TempFilePath = Environ$("temp") & "\"
        TempFileName = "" & Sourcewb.Name & "" & Format(Now, "dd-mmm-yy h-mm-ss")
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
    
        With Destwb
            .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
            On Error Resume Next
            With OutMail
                .Display
                .to = "CUSTOMERMASTERTEAM@SAINT-GOBAIN.COM"
                .CC = ""
                .BCC = ""
                .Subject = Range("F353") & " " & Range("B21") & Range("F354") & Range("B12") & " " & Range("G12") & Range("F355") & Range("B16") & " " & Range("G16") & " " & "CUSTOMER SET UP/CHANGE"
                .Body = "THANK YOU FOR COMPLETING THE FORM."
                .Attachments.Add Destwb.FullName
                .Display
                
            End With
            On Error GoTo 0
            .Close savechanges:=False
        End With
    
            Kill TempFilePath & TempFileName & FileExtStr
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    
        With Application
            .ScreenUpdating = True
            .EnableEvents = True
        End With
    End Sub
    
    
    
    Sub submit()
    '
    ' submit Macro
    '
    
    '
        Application.GoTo Reference:="Module2.Mail_ActiveSheet"
        
         Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
    
        With Destwb
                 On Error Resume Next
                 
            With OutMail
                .Display
                .to = ""
                .CC = ""
                .BCC = ""
                .Subject = Range("F353") & Range("B21") & Range("F354") & Range("B12") & " " & Range("G12") & Range("F355") & Range("B16") & " " & Range("G16") & " " & "CUSTOMER SET UP/CHANGE"
                .Body = "THANK YOU FOR COMPLETING THE FORM.  NEW CUSTOMER SET UPS REQUIRE THE FORM TO BE COMPLETED BY THE TERRITORY MANAGER AND APPROVED BY BOTH THE REGIONAL MANAGER AND THE REGIONAL VICE PRESIDENT.  PLEASE FORWARD THE FORM WITH APPROVALS TO THE CUSTOMER MASTER DATA TEAM.  CUSTOMER SERVICE WILL NOTIFY YOU WHEN YOUR REQUEST HAS BEEN COMPLETED. PLEASE BE SURE TO INCLUDE ALL RECIPIENTS THAT SHOULD RECEIVE THE RETURN NOTIFICATION."
                .Attachments.Add Destwb.FullName
                .Display
                
            End With
            On Error GoTo 0
            .Close savechanges:=False
        End With
    
           Kill TempFilePath & TempFileName & FileExtStr
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    
        
       
    End Sub

  5. #5
    Registered User
    Join Date
    03-21-2015
    Location
    united state
    MS-Off Ver
    2010
    Posts
    4

    Re: Keep Macro in tact Excel to Outlook, the Outook reply back to Excel

    Thanks for your patience. I have never used a forum for assistance before.

+ 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. Switch focus back to Excel from Outlook
    By amphinomos in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-14-2015, 06:45 AM
  2. Excel VBA to get whether Reply has sent or not for a Outlook Mails Item
    By taps in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2012, 05:02 AM
  3. Reply from outlook using Excel
    By avi.ani1703 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 08-13-2012, 05:35 AM
  4. Using Excel VBA Macro to Reply to email in Outlook
    By thechancellor in forum Excel General
    Replies: 0
    Last Post: 06-19-2012, 09:40 PM
  5. [SOLVED] Reply to outlook email from excel script
    By theerdman@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-21-2006, 12:00 PM

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