I have made some progress on this but now have run into another issue. I am trying to connect to the current running instance of Excel. I do not want to create a new instance. Here is the current code
Code: Select all
import sys
import clr
clr.AddReferenceToFileAndPath(r"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.Excel.dll")
import Microsoft.Office.Interop.Excel as Excel
from System.Runtime.InteropServices import Marshal
Excel = Marshal.GetActiveObject("Excel.Application")
I now get the error: AttributeError: 'type' object has no attribute 'GetActiveObject'
From searching around, this seems to be because the IronPython SharpCap is using .NetCore vs .NetFramework which has GetActiveObject. I have tried other solutions but run into the same issue.
Not sure if the above info gives any ideas of what else I can try.