« Previous Next »

Thread: Run Macro Excle from asp .net

Last post 06-04-2008 5:07 AM by Zhao Ji Ma - MSFT. 5 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (6 items)

Sort Posts:

  • 05-30-2008, 9:57 AM

    Run Macro Excle from asp .net

    Hi,

    I have to run a simple Macro on an Excel File (Microsoft Excel 2003) from an asp .net application
    on my local machine (Windows XP) the macro works correctly, but if I run the application on the web server (Windows Server 2003) at the "oXL.Run("Macro1")" instruction the application get stopped.
    I set all the permissions on the server...
    What else can I do? 

    follow my application code:

     Dim oXL As Object = Nothing
     Dim oXLWorkbooks As Object
     Dim oXLWorkbook As Object
     Dim oXLSheets As Object = Nothing
     Dim oXLSheet As Object = Nothing
     Dim oXLRange As Object = Nothing

            Try
                oXL = CreateObject("Excel.Application")
                oXL.DisplayAlerts = False
                oXL.Visible = True
               
                oXLWorkbooks = oXL.Workbooks
                oXLWorkbook = oXLWorkbooks.Open(PathFileMacro, 0, True)

                ************************STOP HERE
               'run the macro            
               oXL.Run("Macro1")
               *********************************************
            Catch ex As Exception
                Exit Function
            Finally


                System.Runtime.InteropServices.Marshal.ReleaseComObject(oXLWorkbook)
                oXLWorkbook = Nothing
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oXLWorkbooks)
                oXLWorkbooks = Nothing
                oXL.Quit()
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oXL)
                oXL = Nothing
                CloseExcel()
                GC.Collect()
                GC.WaitForPendingFinalizers()
            End Try

    thanks....

    Bruno

  • 05-30-2008, 10:18 AM In reply to

    Re: Run Macro Excle from asp .net

    brunello71:
    I set all the permissions on the server...

    What does this mean?  Do you even know what account is accessing the files?

    Jeff

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
  • 05-30-2008, 10:40 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 10:27 AM
    • Central NJ
    • Posts 6,078
    • IIS MVPs

    Re: Run Macro Excle from asp .net

  • 05-30-2008, 11:00 AM In reply to

    Re: Run Macro Excle from asp .net

    I used the "Internet Guest Account" under DCOM Config

  • 05-30-2008, 11:02 AM In reply to

    Re: Run Macro Excle from asp .net

    Thank you tomkmvp,

    but I must use Excel and I can't use another way.....

  • 06-04-2008, 5:07 AM In reply to

    Re: Run Macro Excle from asp .net

    Hi brunello71, 

    brunello71:

    I used the "Internet Guest Account" under DCOM Config


    You can try the suggestions like mentioned in the same KB:

    Configure all instances of the Office application that is started by Automation to run as the Interactive user.
    Configure all instances of the Office application that is started by Automation to run as a specific user.
    Configure your code to run as a specific user by using an MTS/COM+ package and allowing the Office application to inherit the identity of the user that launches the application.

     Detailed steps are also available in this KB.

    Zhao Ji Ma
    Sincerely,
    Microsoft Online Community Support

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
Page 1 of 1 (6 items)