locked
Cannot open and modify excel file with macro via ASP.Net RRS feed

  • Question

  • User-386384640 posted

    Hi,

    I have a c# web application which opens an excel file and modifies few cells and then saves it under different name.

    However, if the excel file contains any macro, the application just hangs at the line where it has to populate the cells with new data. I have configured the DCOM config for MS Excel to use service ID as identity, given the service ID rights for local launch and local activation. If you check task manager, it shows EXCEL process running under IUSER_xxx identity and it has the file locked.

    If the excel file does not contain any macros, then it works fine.

    I spent lot of time googling this but didnt find an answer and few people have posted this exact same problem with no solution. Can ANYONE, please let me know if this is inherint bug in excel or is this something that can be solved?

    thanks in advance for any feedback..

    Thursday, February 5, 2009 8:23 PM

Answers

  • User-1910946339 posted

    Interestingly, Microsoft do not support running Office on a server.  Maybe this is one of the reasons.

    If you are logged in to the server and open the workbook do you get any prompts about macros or security?  If so, you may need to reduce your Excel security level to low (and be aware of the consequences of this).

    Another experiment would be to sign the macros and set Excel to trust macros signed by you.

    Third possibilty.  Do you have to have the macros in the workbook?  I normally add macros to a workbook which does not have the data to be processed.  The macro opens the workbook which has the data before processing it.  That way there are no macros in the workbook which has data.  Not all business situations will allow that configuration but it may be a good option if you are stuck.

    good luck

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 5, 2009 9:47 PM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 6, 2009 2:39 AM

All replies

  • User-1910946339 posted

    Interestingly, Microsoft do not support running Office on a server.  Maybe this is one of the reasons.

    If you are logged in to the server and open the workbook do you get any prompts about macros or security?  If so, you may need to reduce your Excel security level to low (and be aware of the consequences of this).

    Another experiment would be to sign the macros and set Excel to trust macros signed by you.

    Third possibilty.  Do you have to have the macros in the workbook?  I normally add macros to a workbook which does not have the data to be processed.  The macro opens the workbook which has the data before processing it.  That way there are no macros in the workbook which has data.  Not all business situations will allow that configuration but it may be a good option if you are stuck.

    good luck

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 5, 2009 9:47 PM
  • User-386384640 posted

    thanks paul

    - i already tried setting macro security to low. didnt work

    - i need to have the macros. In the application, user input some values and then these values are added to an excel file and this file is saved as a report. Certains users then open these excel files and run the macros to create final reports.

    i have spent lot of time on this without any solution.

    Friday, February 6, 2009 1:46 AM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 6, 2009 2:39 AM