خرید بک لینک

I created an EPLAN API with C#. It uses .NET Framework 4.8.1.

The app gets an opened instance of Excel using Marshal.GetActiveObject to then make changes to the data.

The code works fine and is able to see the opened instance of Excel. However the API doesn't work for 1 client because it can't see the opened instance of Excel.

This means there is some setting on his PC that is causing Marshal.GetActiveObject to fail.

What Excel or PC setting do I need to change to get Marshal.GetActiveObject working on his PC?

I've already tried updating Excel to the latest version and it didn't work. I've been told the client has 64 bit EPLAN and Excel. My API platform is set to Any CPU.

A sample for the code is shown here:

Excel.Application oApp = (Excel.Application)Marshal.GetActiveObject("Excel.Application");
int workbookCount = oApp.Workbooks.Count;

for (int i = 1; i <= oApp.Workbooks.Count; i++)
{
    comboBox_Sheet.Items.Add(oApp.Workbooks[i].Name);
    if (oApp.Workbooks[i].Name == Properties.Settings.Default.Typical_Sheet_Name)
    {
        comboBox_Sheet.SelectedIndex = i;
    }
}

برچسب: نویسنده: استخدام کار تاريخ: شنبه 30 آبان 1405 ساعت: 17:40

صفحه بندی