Search code examples
excelvba

VBA project explorer still showing the excel workbooks which are closed by the macro


I have created a macro that opens a excel workbook and performs some operations and then at the end it closes the file.The macro is running fine.

Now, when I open my VBA Project explorer in the vba editor. It shows the list of files that have been opened by the macro even though they are closed. How do i remove them from the project explorer window ? why its still showing the excel workbooks, which are already closed ? is there anyway to fix it or its a limitation?


Solution

  • I found the answer myself.

    Dim Excel_workbook As Excel.Workbook
    Set Excel_workbook = Workbooks.Open("somefile name");
    ' some code goes here 
    ' at the end write the below statement
    Set Excel_workbook = Nothing 'worked, I found at the 12 page of google search
    

    This is the link that helped me http://www.mrexcel.com/forum/showthread.php?t=50086