/// <summary> /// Advises this ApplicationRuntimeAdapter of the newly activated workbook's full name. /// </summary> /// <param name="name">The full name of the activated workbook.</param> public void SetActiveWorkbook(string name) { m_activeWorkbookName = name; if (name == null) { m_activeAdapter = null; } else { m_activeAdapter = GetAdapter(name); } }
/// <summary> /// Returns the WorkbookRuntimeAdapter associated with a workbook whose name is supplied. If no /// such adapter exists then one is created. /// </summary> private WorkbookRuntimeAdapter GetAdapter(string workbookName) { WorkbookRuntimeAdapter a; lock (m_workbookAdapters) { if (!m_workbookAdapters.TryGetValue(workbookName, out a)) { a = new WorkbookRuntimeAdapter(); m_workbookAdapters[workbookName] = a; } } return a; }
/// <summary> /// Advises this ApplicationRuntimeAdapter that the most recently active workbook has been /// deactivated. /// </summary> /// <remarks> /// The active workbook's name may change. Because this ApplicationRuntimeAdapter uses a /// workbook's full name to identify the workbook's associated WorkbookRuntimeAdapter, it must be /// advised of any name change. Unfortunately there is no Excel interop event for this. /// </remarks> /// <param name="name">The full name of the deactivated workbook.</param> public void DeactivateWorkbook(string name) { string awn = m_activeWorkbookName; if (awn != null && awn != name) { // The active workbook's name has been changed MapAdapter(awn, name); } m_activeWorkbookName = null; m_activeAdapter = null; }