How to use OLE in F#?

Hi, we are using a software in our company that has an ole interface to remote control it. This software is written in C++.

In Python I can use the makepy script from pywin32 to generate a module that contains any classes and constants of the ole interface.

But I want to use F# instead because I want a more functional approach and I have some issues with Python and ole, but I don’t know how to do this in F#. Are there any documentations or examples that not only use Excel?

Yes, you can use F# to work with the OLE interface. To do that you need to use a .NET Framework library called “Microsoft.Office.Interop”. This library contains the types needed to work with the OLE interface.
open Microsoft.Office.Interop

let wordApp = new ApplicationClass()
let doc = wordApp.Documents.Add()
let para = doc.Paragraphs.Add()
let rng = para.Range
rng.Text ← “Hello from F#”
doc.SaveAs(“Hello.docx”)
doc.Close()
wordApp.Quit()
You can modify this code to use other applications that work with the OLE interface and the various methods and properties that are available in those applications. The Microsoft.Office.Interop library documentation contains additional examples and reference information that can help you in using F# to work with the OLE interface.

You could have answered whether it worked or not, whether my help was useful or not.

I’m sorry for the late answer. I had no time to continue with this project. Until now I was able to open the program, but I wasn’t able to call any function.

I will continue the project asap end report any success or failure.

As I mentioned in the first post the software I try to use is a custom software, no MS Office.

So your example doesn’t really help, sorry.

Meanwhile I can connect to the application, but I can’t call any functions. I’m currently not at my PC so I can’t post any details. Maybe this afternoon or at the weekend.