Im trying to make a macro in one session of excel that saves a particular workbook in another session of excel.

Lets say i have Workbook1 and Workbook2 and i have opened them in different excel sessions.What i want is to make macro that saves Workbook2 from Workbook1.

  • Can you share the code you've tried? This way, we can see where it's going wrong. – Dave Aug 22 '14 at 12:06

Although a macro is stored in a specific workbook, every macro (or SUB) is aware of (and has access to) all workbooks that are open in Excel. Access to other workbooks is most easily obtained by using the Workbooks collection (Application.Workbooks) or by referencing a particular workbook by index (Application.Workbooks(1) or by name Application.Workbooks("SomeWorkbook.xlsx"). To save a file, you can use the .Save method of a workbook class.

To answer your question:

Sub SaveSomeWorkbook()
End Sub
  • yes this works but if both workbooks are opened in one session of excel. if they are opened in different sessions of excel it gives me error "script out of range" – HristoGeorgiev Aug 22 '14 at 15:28
  • Can you describe/clarify how you open two sessions of Excel? – agtoever Aug 22 '14 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.