In my solution, I have 2 projects.
One of them is the controller, which in the final product is used to check whether execution is performed from the console input / not by the user and, therefore, will perform the required background changes based on the imput from the xml file or if the execution was issued by user input, which will open the interface.
Not user input may be a scheduled task or something similar, but this is already at a different time, and I'm just writing this for some context.
In both cases, sooner or later, there is a need to access text documents and read, write, and change the properties of the document.
To do this, I created a VSTO-Word-Addin with the necessary functions and until that moment I hard-coded the paths and did not return the results anywhere except for another document.
Since I am sure that my code in VSTO itself works, I wanted to extend the prototype to the next level and tried to add connections between the console and VSTO.
For testing, I simplify the process a bit and just try to establish a connection between the console and VSTO without any custom installation and try to execute some methods to check the functionality of my VSTO.
My approach was to open a console that would then open Word / addin, open the file hidden and do the magic.
First of all, you need to set the path to open the document, and then call several methods with the returned values.
In this case, my VSTO returns true for
SetCustomProperty
and a new list of tuples for
GetCustomProperties
.
, , WinForms/WPF/Console VSTO AddIn AddIn.
, , :
MSDN
VSTO
, , ,
Globals
Globals , MSDN
, , , , VSTO- ?
:
, :
[ComVisible(true)]
public interface IPropertyReadWriter
{
bool Open(string Path);
bool SetCustomProperty(String Name, PropertyTypes Type, object Value);
List<Tuple<String, PropertyTypes, object>> GetCustomProperties();
}
[ComVisible(true)]
public class PropertyReaderWriter : IPropertyReadWriter
{
public List<Tuple<string, PropertyTypes, object>> GetCustomProperties()
{
return new List<Tuple<string, PropertyTypes, object>>();
}
public bool Open(string Path)
{
return false;
}
public bool SetCustomProperty(string Name, PropertyTypes Type, object Value)
{
return false;
}
}
, MSDN -:
object addInName = "ExcelImportData";
Office.COMAddIn addIn = Globals.ThisAddIn.Application.COMAddIns.Item(ref addInName);
ExcelImportData.IAddInUtilities utilities = (ExcelImportData.IAddInUtilities)addIn.Object;
utilities.ImportData();
, , Globals outsite VSTO?
, , :
, , MSDN.
VSTO AddIn #?