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

Microsoft 365 and Office | Development | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 60,326 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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.