Re: CreateObject("Excel.Application",MyServer)

Discussion in 'ASP .Net' started by KC, Oct 5, 2004.

  1. KC

    KC Guest

    Hi,
    I finally got the CreateObject("Excel.Application",\\MyServer) working but I
    have another serious problem.
    I open the Excel.Application in remoter server and open the workbook and
    read and process the data. But the process is done, the Excel instance
    doesn't close and it creates a new instance every time. Here is my code.

    Please help..

    Dim objExcelApp As Excel.Application
    Dim objWorkBook As Excel.Workbook
    Dim objWorkSheet As Excel.Worksheet
    Dim objRange As Excel.Range
    objExcelApp = CType(CreateObject("Excel.Application",
    ConfigurationSettings.AppSettings("AppServer")), Excel.Application)
    objExcelApp.DisplayAlerts = False
    objWorkBook = CType(objExcelApp.Workbooks.Add(WorkBookPath), Excel.Workbook)
    objWorkSheet =
    CType(objWorkBook.Worksheets(ConfigurationSettings.AppSettings("WorkSheetPat
    h")), Excel.Worksheet)


    ''Do the processing......................

    ReleaseComObject(objWorkSheet)
    ReleaseComObject(objWorkBook)
    ReleaseComObject(objExcelApp)

    objRange = Nothing
    objWorkBook = Nothing
    objWorkSheet = Nothing
    objExcelApp = nothing

    If Not IsNothing(objExcelApp) Then
    objExcelApp.DisplayAlerts = False
    objExcelApp.Quit()
    objExcelApp = Nothing
    End If

    GC.Collect()






    "Dmitriy Lapshin [C# / .NET MVP]" <> wrote
    in message news:...
    > Hi KC,
    >
    > You can grant permissions to the user your ASP .NET app runs under to

    access
    > the Excel COM server by running dcomcnfg on the "MyServer" machine. For
    > this, the aforementioned user should be a domain user. You could possibly
    > also impersonate a domain user with enough permissions before

    instantiating
    > and using the Excel object.
    >
    > --
    > Sincerely,
    > Dmitriy Lapshin [C# / .NET MVP]
    > Bring the power of unit testing to the VS .NET IDE today!
    > http://www.x-unity.net/teststudio.aspx
    >
    > "KC" <> wrote in message
    > news:...
    > > Hi,
    > > I have code similar to this..
    > > Dim xlApp As Object
    > > xlApp = CreateObject("Excel.Application", "\\MyServer")
    > >
    > > The call is from a asp.net (Intranet) application. \\Myserver is a

    network
    > > computer in the same domain as web server. The only way I can get this
    > > call
    > > worked is when I add the user who logs on to the web site as
    > > Administrators.
    > > I need to get this working without having to make the user

    administrator.
    > > Any suggestion?
    > > Thanks,
    > > CK
    > >
    > >

    >
    KC, Oct 5, 2004
    #1
    1. Advertising

  2. You should read the article by Steve Orr on how to do this:

    http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309so_l/asp200309so_l.asp

    Are you using Microsoft's interop components? One technique that may help is
    to call

    System.Runtime.InteropServices.Marshal.ReleaseComObject(xl)

    BTW, why the excessive/impolite cross-posting? (Trimmed)

    "KC" <> wrote in message
    news:...
    > Hi,
    > I finally got the CreateObject("Excel.Application",\\MyServer) working but
    > I
    > have another serious problem.
    > I open the Excel.Application in remoter server and open the workbook and
    > read and process the data. But the process is done, the Excel instance
    > doesn't close and it creates a new instance every time. Here is my code.
    >
    > Please help..
    >
    > Dim objExcelApp As Excel.Application
    > Dim objWorkBook As Excel.Workbook
    > Dim objWorkSheet As Excel.Worksheet
    > Dim objRange As Excel.Range
    > objExcelApp = CType(CreateObject("Excel.Application",
    > ConfigurationSettings.AppSettings("AppServer")), Excel.Application)
    > objExcelApp.DisplayAlerts = False
    > objWorkBook = CType(objExcelApp.Workbooks.Add(WorkBookPath),
    > Excel.Workbook)
    > objWorkSheet =
    > CType(objWorkBook.Worksheets(ConfigurationSettings.AppSettings("WorkSheetPat
    > h")), Excel.Worksheet)
    >
    >
    > ''Do the processing......................
    >
    > ReleaseComObject(objWorkSheet)
    > ReleaseComObject(objWorkBook)
    > ReleaseComObject(objExcelApp)
    >
    > objRange = Nothing
    > objWorkBook = Nothing
    > objWorkSheet = Nothing
    > objExcelApp = nothing
    >
    > If Not IsNothing(objExcelApp) Then
    > objExcelApp.DisplayAlerts = False
    > objExcelApp.Quit()
    > objExcelApp = Nothing
    > End If
    >
    > GC.Collect()
    >
    >
    >
    >
    >
    >
    > "Dmitriy Lapshin [C# / .NET MVP]" <> wrote
    > in message news:...
    >> Hi KC,
    >>
    >> You can grant permissions to the user your ASP .NET app runs under to

    > access
    >> the Excel COM server by running dcomcnfg on the "MyServer" machine. For
    >> this, the aforementioned user should be a domain user. You could possibly
    >> also impersonate a domain user with enough permissions before

    > instantiating
    >> and using the Excel object.
    >>
    >> --
    >> Sincerely,
    >> Dmitriy Lapshin [C# / .NET MVP]
    >> Bring the power of unit testing to the VS .NET IDE today!
    >> http://www.x-unity.net/teststudio.aspx
    >>
    >> "KC" <> wrote in message
    >> news:...
    >> > Hi,
    >> > I have code similar to this..
    >> > Dim xlApp As Object
    >> > xlApp = CreateObject("Excel.Application", "\\MyServer")
    >> >
    >> > The call is from a asp.net (Intranet) application. \\Myserver is a

    > network
    >> > computer in the same domain as web server. The only way I can get this
    >> > call
    >> > worked is when I add the user who logs on to the web site as
    >> > Administrators.
    >> > I need to get this working without having to make the user

    > administrator.
    >> > Any suggestion?
    >> > Thanks,
    >> > CK
    >> >
    >> >

    >>

    >
    >
    Ken Cox [Microsoft MVP], Oct 5, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Casey Brown

    CreateObject question

    Casey Brown, Dec 15, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    415
    Casey Brown
    Dec 15, 2003
  2. Raúl Martín
    Replies:
    1
    Views:
    10,809
    Natty Gur
    May 13, 2004
  3. ashish
    Replies:
    1
    Views:
    438
    ashish
    Aug 14, 2007
  4. Sagar

    Server.CreateObject Vs CreateObject

    Sagar, Jan 15, 2008, in forum: ASP General
    Replies:
    2
    Views:
    335
    Sagar
    Jan 15, 2008
  5. Sze
    Replies:
    1
    Views:
    1,185
    Steven Cheng
    Jul 28, 2010
Loading...

Share This Page