Results 1 to 8 of 8

Thread: Excel issue in Local web server

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Thumbs up Excel issue in Local web server

    Hi all,
    I am using this code to get th ProcessID of newly Created Excel.

    Code:
    Imports Microsoft.VisualBasic
    Imports Microsoft.Office.Interop
    Public Class Class1
        <Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True)> _
      Private Shared Function GetWindowThreadProcessId(ByVal hwnd As Integer, _
                                ByRef lpdwProcessId As Integer) As Integer
        End Function
    
        Private processId As Integer
        Sub New()
            Dim oExcel As Excel.Application
            oExcel = CreateObject("Excel.Application")
            GetWindowThreadProcessId(oExcel.Hwnd, processId)
            oExcel.Quit()
            System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
            oExcel = Nothing
        End Sub
    End Class
    This code returns the Process ID Correctly with Virtual Server
    Now I deployed it using a Website, and the ProcessID is 0

    Has anyone experienced with this ?
    Last edited by danasegarane; Jan 29th, 2010 at 07:32 AM.
    Please mark you thread resolved using the Thread Tools as shown

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Excel issue in Local web server

    Hey,

    Ok, I have to ask, why are you creating an instance of Excel, to simply close it again?

    Gary

  3. #3
    Hyperactive Member nepalbinod's Avatar
    Join Date
    Sep 2007
    Posts
    293

    Re: Excel issue in Local web server

    Did you put a breakpoint to discover which line is the first culprit.

  4. #4

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Excel issue in Local web server

    Quote Originally Posted by gep13 View Post
    Hey,

    Ok, I have to ask, why are you creating an instance of Excel, to simply close it again?

    Gary
    Hi Gary. Its only a sample. I am trying to automate excel.

    Thanks Dana
    Please mark you thread resolved using the Thread Tools as shown

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Excel issue in Local web server

    Hey,

    Ah, ok, that makes a bit more sense then

    I take it Excel is installed on the server that you are running the site on, correct?

    Gary

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Excel issue in Local web server

    Your web server will likely clamp down on what your web application is allowed to do. If you want to automate Excel, use the Primery Interop Assemblies for Office and work with the Excel object there by referencing the class libraries directly.

    But this also depends on what you're trying to do. If all you want to do is produce an XLS as part of a report, you could just as well use an HtmlTextWriter.

  7. #7

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Excel issue in Local web server

    Hi Mendhak,
    I was thinking of that, But my report contains nearly 30 pages which is very tedious to create
    Please mark you thread resolved using the Thread Tools as shown

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Excel issue in Local web server

    Alright, but this is on the web server. Even if you automate Excel, you'll have to create some sort of an interface anyways.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width