Results 1 to 5 of 5

Thread: Avoid a message when closing Excel File

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Location
    Dist 2, Ho Chi Minh City,Viet Nam
    Posts
    13

    Avoid a message when closing Excel File

    Hi, There

    I am creating a macro.
    The macro open a file, copy an area & paste to another area.
    The this file to be closed. But I always have a massage (See file attached) . This will delay the process as I have to choose "Yes" or "No".

    My Question : How do I avoid this message.

    Thank you for your help.
    Attached Files Attached Files

  2. #2
    Fanatic Member JCScoobyRS's Avatar
    Join Date
    Oct 2002
    Location
    Some Mountain in Colorado
    Posts
    677
    VB Code:
    1. objExcel.DisplayAlerts = False

    objExcel is the Excel.Application. HTH, Jeremy

    P.S. - If you need more assistance, let me know.
    He who listens well, speaks well.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Location
    Dist 2, Ho Chi Minh City,Viet Nam
    Posts
    13
    Thanks for your reply. In fact I do not understand clearly.
    Can you add to this macro so that the message is not shown :
    Sub XX()
    Workbooks.Open Filename:="C:\SAPworkdir\tg1.xls"
    Range("A1:C500").Select
    Selection.Copy
    Windows("CL.xls").Activate
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("tg1.xls").Activate
    ActiveWorkbook.Save
    ActiveWindow.Close
    End Sub

    Thanks a lot

  4. #4
    Lively Member
    Join Date
    Jun 2003
    Location
    france
    Posts
    71
    what i usually do is that i copy an empty cell befor quiting
    and if you don't want to save you type this instead of ActiveWorkbook.Save
    Active workbook.saved = true

    visual basic code:--------------------------------------------------------------------------------
    Sub XX()
    Workbooks.Open Filename:="C:\SAPworkdir\tg1.xls"
    Range("A1:C500").Copy
    Windows("CL.xls").Activate
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Windows("tg1.xls").Activate
    Range("D1").copy
    ActiveWorkbook.Save
    ActiveWindow.Close
    End Sub
    --------------------------------------------------------------------------------

    pour une fois que je peux aider

  5. #5
    Fanatic Member JCScoobyRS's Avatar
    Join Date
    Oct 2002
    Location
    Some Mountain in Colorado
    Posts
    677
    What you need to add to your macro is this:

    VB Code:
    1. Application.DisplayAlerts = False

    I neglected to remember you were doing VBA and not VB. Put that line anywhere in your macro before saving and closing. Let me know, Jeremy
    He who listens well, speaks well.

Posting Permissions

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



Click Here to Expand Forum to Full Width