+ Reply to Thread
Results 1 to 4 of 4

Excel generated macro , close my excel file at the end

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    ahmedabad
    MS-Off Ver
    Excel 2000
    Posts
    3

    Excel generated macro , close my excel file at the end

    I am using below macro to generate an outlook email using data from my "data.xls" file.
    As I run the macro, it creates my resulted email & close my data.xls file without warning me.
    I want to update this macro as it do not close my data.xls file.
    By all other means this macro is fine.Can anyone answer how to update it that it doesnt close my excel file with data.


    Sub RFQ()
    Application.Goto Reference:="R6C1"
    Selection.Copy
    Range("A7").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Dim OutApp As Object: Set OutApp = CreateObject("Outlook.Application")
    Dim OutMail As Object: Set OutMail = OutApp.createitem(0)
    Dim stFname As String
    Dim cell As Range

    On Error Resume Next
    For Each cell In Range("A1:A5")
    With OutMail
    .To = Range("c1")
    .CC = Range("c3")
    .BCC = Range("c2")
    .Subject = Range("n1")
    .Body = Range("n2")
    .display
    End With
    Next cell

    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub
    Last edited by donotuse111; 05-31-2013 at 09:39 AM.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Excel generated macro , close my excel file at the end

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Excel generated macro , close my excel file at the end

    There is nothing in this code that would cause the problem you describe.

    Likely, the workbook is corrupt. Copy the data to a new workbook, move the code over and try it again.
    David
    (*) Reputation points appreciated.

  4. #4
    Registered User
    Join Date
    01-18-2013
    Location
    ahmedabad
    MS-Off Ver
    Excel 2000
    Posts
    3

    Re: Excel generated macro , close my excel file at the end

    this didnt work, as i need to keep my excel data file open after running macro.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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