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 ?
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
Re: Excel issue in Local web server
Did you put a breakpoint to discover which line is the first culprit.
Re: Excel issue in Local web server
Quote:
Originally Posted by
gep13
Hey,
Ok, I have to ask, why are you creating an instance of Excel, to simply close it again?
Gary
Hi Gary. :wave: Its only a sample. I am trying to automate excel.
Thanks Dana
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
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.
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
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.