0
votes

My macros are stored in the personal workbook. I have 3 workbooks open. One workbook is generated always from a web application. Therefore the name is always changing (I have no influence on the web app). However, the two other workbook are named properly. I would like to deactivate at the end of the subrutine the two named macros in order to get back at the original exported excel file.

Version 1: I activate the exported excel file. In this case I have to modify the macro at each time when I work with this file.

Windows("exported_excel_file.xlsx").Activate

Version 2: I deactive the two other excel files. But I do not find a deactivate method:

Windows("exported_excel_file.xlsx").Deactivate

What kind of solutions are avaiable?

1
Set your books instead? - findwindow
Only 1 workbook is active at any one time, so by activating a workbook you are inherently deactivating the other workbooks - SierraOscar

1 Answers

1
votes

Iterate through the workbooks instead:

For Each wb In Application.Workbooks
    Select Case wb.Name
        Case "exported_excel_file.xlsx"
        Case "some_other_file.xlsx"
        Case Else: wb.Activate: Exit For
    End Select
Next