Say I created a program with a textbox on it and a button that does something with the text in the textbox.
How do I make that program COM visible, load it and automate it from another project?
My goal is to be able to automate the program using COM:
Dim myProj as object = createObject("myProgram")
myProj.setText("Hello World")
myProj.buttonClickEvent()
Similar to how you can load a new excel and automate via interop:
dim xl as object = createobject("excel.application")
Dim wb as object = xl.workbooks.add
Dim ws as object = wb.worksheets(1)
ws.cells(1,1) = "i love stackoverflow"
How do programs do this? I’m looking for the answer VB.Net specific. Thank you in advance!
This page should give you the necessary details you will need: http://www.codeproject.com/KB/vb/MusaExposingCOM.aspx
This process that you want is normally called “exposing a COM interface”, this is done via early binding or late binding. Early binding means the methods (locations) are known when you create your program, late binding means the methods (locations) are looked up when you run the program. Late binding, I think, is a little slower but the lookup only has to happen once. This is negligible.