Why I can not open remote Office document in browser?(vb.net)

Hello,everybody.

I have a problem like this:
I want to click a doc hy-link in the client browser to call local office application and open an office document saved in the server,like Word or Visio.but it is always wrong.

I use VB.NET, and the codes:

'WebForm1.aspx
Imports OWSSUPP 'an Office 2003 DLL

Public Class WebForm1
Inherits System.Web.UI.Page

Dim openDoc As New OWSSUPP.COWSNewDocumentClass

Private Sub btnEditFile_Click() Handles btnEditFile.Click
Dim bFileOpened As Boolean
Try
bFileOpened = Me.openDoc.ViewDocument("
http://localhost/UpFiles/1.doc")
Catch ex As Exception
Me.lstMsg.Items.Add(ex.ToString) 'can not catch anything
End Try

If bFileOpened = True Then
Me.lstMsg.Items.Add("File Opened Right!")
Else
Me.lstMsg.Items.Add("File Opened Wrong!") 'always show this
End If

End Sub

The OWSSUPP.DLL class browser:
Interop.OWSSUPP
+{}OWSSUPP
+Interface:COWSNewDocument
+Class:COWSNewDocumentClass
+Interface:COWSStssyncHandler
+Class:COWSStssyncHandlerClass
+Interface:OWSExcelLauncher

My Server:
Windows Server 2003 Enterprise Edition and Server Pack 1;
Visual Studio .NET 2003 Enterprise Architect
IIS6.0 and local disk format is NTFS
the virtual dir is Read and Write

My Browser:
Internet Explorer 6.0.3790.1830 SP1

Thanks everybody here!



Answer this question

Why I can not open remote Office document in browser?(vb.net)

  • OL

    Opening a document programmatically from a Web location is a common task. However, I noticed that your ASP.NET server-side code is trying to open the document on the server. This is not supported and your code is trying to do something that you really don't want to do.

    What you want to do is hand the link off so that the client can open it up, a simple re-direct really. I've done this many times, and it works as expected.

    It is helpful to remember that this forum is mainly for issues that directly pertain to the Visual Studio Tools for Office tools per se. So you will be best served by posing this question to a forum or newsgroup wholly dedicated to application-specific issues such as yours. Here is a link to resources that will help you

    http://msdn.microsoft.com/asp.net/

    John.



  • Why I can not open remote Office document in browser?(vb.net)