View Excel Document in VB.Net Form

  • Thread starter Thread starter Linda U
  • Start date Start date
L

Linda U

I am trying to view an excel document on a windows form. I am using a
webbrowser control as suggested in past topics and I am able to display
the document fine. The problem I'm having is that an excel shell is
opened in the background, is there a way to keep this from happening?
I can use the webbrowser control ot open word documents, pdf files,
bmp's, and jpeg's without this happening what is the difference with
excel?

Thanks for your help
 
¤ I am trying to view an excel document on a windows form. I am using a
¤ webbrowser control as suggested in past topics and I am able to display
¤ the document fine. The problem I'm having is that an excel shell is
¤ opened in the background, is there a way to keep this from happening?
¤ I can use the webbrowser control ot open word documents, pdf files,
¤ bmp's, and jpeg's without this happening what is the difference with
¤ excel?

What do you mean by "shell"?

Could you post the code you are using?


Paul
~~~~
Microsoft MVP (Visual Basic)
 
By shell I mean that it opens excel in the background, the dcument
itself doesn't show just a blank excel spreedsheet. And then after you
close the window that has the webbrowser in it the backgroung excel
stays open. Here is the code I'm using...

'The excel file is stored in an SQL Image so I stream it into a file
If dr.HasRows Then
dr.Read()
Dim b(dr.GetBytes(0, 0, Nothing, 0, Integer.MaxValue) - 1)
As Byte
dr.GetBytes(0, 0, b, 0, b.Length)
strTitle = dr.Item("Title")
dr.Close()

Dim fs As New System.IO.FileStream(DestFilePath & strTitle,
IO.FileMode.Create, IO.FileAccess.Write, IO.FileShare.None)
fs.Write(b, 0, b.Length)
fs.Close()

oDocument = Nothing
AxWebBrowser1.Navigate(DestFilePath & Trim(strTitle))

Linda
 
¤ By shell I mean that it opens excel in the background, the dcument
¤ itself doesn't show just a blank excel spreedsheet. And then after you
¤ close the window that has the webbrowser in it the backgroung excel
¤ stays open. Here is the code I'm using...
¤
¤ 'The excel file is stored in an SQL Image so I stream it into a file
¤ If dr.HasRows Then
¤ dr.Read()
¤ Dim b(dr.GetBytes(0, 0, Nothing, 0, Integer.MaxValue) - 1)
¤ As Byte
¤ dr.GetBytes(0, 0, b, 0, b.Length)
¤ strTitle = dr.Item("Title")
¤ dr.Close()
¤
¤ Dim fs As New System.IO.FileStream(DestFilePath & strTitle,
¤ IO.FileMode.Create, IO.FileAccess.Write, IO.FileShare.None)
¤ fs.Write(b, 0, b.Length)
¤ fs.Close()
¤
¤ oDocument = Nothing
¤ AxWebBrowser1.Navigate(DestFilePath & Trim(strTitle))
¤

By "background" do you mean you can see the Excel user interface, or that the application is running
in the background (invisible).

Does anything display in the WebBrowser control?


Paul
~~~~
Microsoft MVP (Visual Basic)
 
By background I mean the excel user interface actually launches,
sometimes as the active window sometimes not. I looks the same as if
you open excel with no document, it shows that excel is running in the
taskbar. The actually spreadsheet that I'm trying to view shows in the
WebBrowser control not in the excel user interface.

Thanks for your help,
Linda
 
¤ By background I mean the excel user interface actually launches,
¤ sometimes as the active window sometimes not. I looks the same as if
¤ you open excel with no document, it shows that excel is running in the
¤ taskbar. The actually spreadsheet that I'm trying to view shows in the
¤ WebBrowser control not in the excel user interface.
¤

That's interesting because I can produce this issue with Microsoft Word but not Excel. I'll see if I
can figure out what might be happening.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
¤ Thank you. This issue is the only think keeping me from releasing the
¤ program update.

OK, it doesn't appear that I can repro this behavior using Word anymore so I'm thinking it's a
system configuration issue. Try opening an Excel document directly from Internet Explorer. This
might fix the problem as I can't think of anything else I did to resolve the issue with Word.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Unfortunently this didn't fix the problem. But I think you may be
right about a system configuration issue, when I opened the excel
document in Internet Explorer I got two windows one with the document
one blank! At least this gives me a place to start looking.

Thanks for all you help!
Linda
 
¤ Unfortunently this didn't fix the problem. But I think you may be
¤ right about a system configuration issue, when I opened the excel
¤ document in Internet Explorer I got two windows one with the document
¤ one blank! At least this gives me a place to start looking.
¤

The below article could possibly be relevant:

http://support.microsoft.com/?kbid=162059

The only other thing I can think of is that there is something in the Workbook itself, such as a
macro, that is causing this behavior.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
I have now tested other PC's in the department and it seems that this
behavior is only happening on one particular model of computer. All
these computers would of had the same inital setup. I found this
artical yesterday, I already had the box checked to open in the browser
window, if I uncheck the box it opens document in excel (which is what
you would expect). The reg hacks listed tell you how to force it to
open excel so these don't help. Thanks again for all your help, if you
think of anything else let me know. If I ever figure out how to get
this to work correctly I'll post the answer.
 
I am having a similar problem , we have had an office upgrade recently
and since then , viewing office documents cause the web browser control
to behave differently , did you ever get a solution for this
 
I never figured out the solution to my problem. Right now the users
just get an extra blank window if they open an excel document. The
above fix did not help me because I already have the box checked to
open in the browser window, which does happen I just get the extra
window as well. If you figure out a fix for this problem please let me
know, it's only a matter of time before my users start complaining
about the extra window :-)
 
Back
Top