64-bit conversion explanation what to do now?

Richie Mathison 0 Reputation points
2024-05-01T14:50:44.15+00:00

https://learn.microsoft.com/en-us/previous-versions/office/troubleshoot/office-developer/automate-excel-from-visual-basic-net

this does not work I read somewhere else that this is because of the 64-bit conversion and this code sample is written the 32-bit way

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,542 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 48,976 Reputation points
    2024-05-01T15:02:55.11+00:00

    Please clarify what issue you're having. Automating Office works fine in x86 or x64. Just add the COM object to your code and you can automate Office. Office runs out of process so it doesn't matter what bitness your app is. The COM interop assembly works with either mode. In general Office x86 is installed on a machine. Note that some Office components (like the Access runtime) have additional requirements but Excel should be fine.

    As an example, here is the simplest C# code that can open Excel and create a new XLSX file. Works irrelevant of whether app is compiled as x86 or x64.

    var app = new Microsoft.Office.Interop.Excel.Application();
    
    var book = app.Workbooks.Add();
    book.SaveAs2(@"test.xlsx");
    
    app.Quit();
    

    If you are having issues with your code then please post the code you are having issues with along with the error(s) you're seeing.

    0 comments No comments