/// <summary> /// Exports components to specified path and updates configuration file /// </summary> /// <param name="args">info about specified path, selected components etc. </param> /// <param name="config">a reference to a configuration file</param> /// <returns></returns> public virtual bool ExportComponents(Events.ExportEventArgs args, Configurations.ConfigurationBase config) { try { List <_VBComponent> comps = args.SelectedComponents.Select(x => x.VbComponent).ToList(); foreach (var component in comps) { string fullPath = Path.Combine(args.Path, component.Name + VbeExtensions.GetExtension(component.Type)); if (component.Type == vbext_ComponentType.vbext_ct_Document) { string text = ""; if (component.CodeModule.CountOfLines > 0) { text = component.CodeModule.get_Lines(1, component.CodeModule.CountOfLines); } File.WriteAllText(fullPath, text); } else { component.Export(fullPath); } } config.SaveProject(_projectName, args.Path); return(true); } catch (COMException comEx) { throw new COMException(string.Format(strings.ExportComExceptionText, comEx.ErrorCode), comEx.ErrorCode); } }
/// <summary> /// Initializes internal objects /// </summary> /// <param name="vbe">a reference to VBE</param> /// <param name="config">a reference to configuration file</param> /// <param name="projectName">a name of the active VBA project</param> public ImportModel(VBE vbe, ConfigurationBase config, string projectName) { _vbe = vbe; _config = config; _projectName = projectName; }