Results 1 to 3 of 3

Thread: When i am opening another workbook,I need to save and close the existed workbook?

  1. #1

    Post When i am opening another workbook,I need to save and close the existed workbook?



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi All,

    How can i do like this.

    I am opening second workbook from the first workbook at that time how can i save and close the first workbook.

    So, that one workbook should open at a time.

    This is how i tried but not succeeded.

    Code:
     
    Application.Workbooks.Open ("E:\Second_Data.xlsx")
    Application.Workbooks("E:\First_Data.xlsx").Save
    Application.Workbooks("E:\First_Data.xlsx").Close
    Please help to solve this.

    Regards
    Kumar

  2. #2
    Code:
    If WorkbookIsOpen("First_Data.xlsx") Then
    Workbooks("First_Data.xlsx").Close savechanges:=True
      End If

  3. #3

    Post

    Hi Tommy,

    Thanks for the reply.
    I got the solution to it.

    Code:
    ThisWorkbook.Save
    ThisWorkbook.Close
    Regards
    Kumar

Posting Permissions

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