Helpful Information
 
 
Category: ASP.NET
open Word document with VB.net

Greetings!

I'm having trouble finding the correct way to open a Microsoft Word document with asp.net (VB). I read something about adding a COM reference to the Word Object Library (or something of the sorts), but the example uses Visual Studio, and I am working in Dreamweaver. If it's a matter of importing the correct namespace, I'm not sure which one to use. Otherwise, I'm at a loss.

Here's the procedure code I have so far:


Dim appWord As New Word.Application
Dim docWord As New Word.Document

docWord = appWord.Documents.Open("L:\SWPPP\SWPPPBookMerge.doc")

Further more, I'm hoping to merge data from a table into this document, but I figured opening it would be a good first step.

Thanks in advance!

B. Drake

Your code should work, make sure the asp.net user (is a technical user) has started MS Word once (otherwise the msi package for Word will try to launch and that fails most of the time) AND make sure the location of the file (L: looks like a mapping to me, so the user has to be able to get access to that drive, better use UNC paths (like \\servername\sharename\dirname\filename.doc)) to make sure it is user independant

good luck!

Thanks for the advice!

However, I can't even get it to compile without errors, as it doesn't recognize Word.Application or Word.Document.

If it's a matter of adding the correct namespace, I'm not sure which one I need. Is there something that has to be configured on the server to add the Word Object Library or something of the sorts?

Much obliged.

Imports Microsoft.Office.Interop

Beautiful, thank you sir.

I'm still getting an error on compiliation:

Type 'Word.Application' is not defined.

I thought the imports would fix it, but appearantly not.

I've put the Imports statement at the top of the page with the other
<%@ import Namespace="...... statements, but no dice.

Any ideas?

Appreciate it!

Which office version are you using?

If it is office 2003, the Imports should work, if it is an older version, you should first create a com reference. Don't know how dreamweaver works on that area.

Sorry

Appreciate it sir.

I'm using office 2003, and I'll keep looking for a way to add the COM wrapper.

Thanks!

Does dreamweaver use code-behind files? Or does it put the asp.net serverside code in the aspx page itself?

I have tried a client application with the imports statement, so if DW uses code behind, it should go there

Best to my knowledge, all the server-side code is still on the .aspx page itself. Since this is an inter-office application, I'm not to worried about concealing the behind-the-scenes code.

Also, when I add the Imports..... statement below all the <%@ import Namespace....%>, it treats it like text that belongs on the page itself (visible to the page user).

I thought surely there's a way to do this, since it seems relatively simple to do with Visual Studio.

Thanks again sir!

Hi reverendleo,

Are you compiling your code as a dll file? I have developed a project at work using dreamweaver with asp.net and vb.net. You will need to put the dll file of the Word COM object in your compile command prompt. Example:

vbc /r:system.dll /r:system.data.dll /t:library /out:..\bin\Login.dll ..\Authenticate\Login.vb

You might need to down load the Imports Microsoft.Office.Interop dll from miscrosoft if it only comes with visual studio and place it in the bin directory.

My next project at work will be involved in using MS word with my .net pages. So I'm looking for similar solutions. Let me know how you get on.

Using Word interop is a bad idea in an ASP.NET web page. Something to do with the threading models used, I think.

It is better to write a Word XML file to the response stream and set the http headers so that the client browser opens the "page" in Word.

Greetings!

I'm having trouble finding the correct way to open a Microsoft Word document with asp.net (VB). I read something about adding a COM reference to the Word Object Library (or something of the sorts), but the example uses Visual Studio, and I am working in Dreamweaver. If it's a matter of importing the correct namespace, I'm not sure which one to use. Otherwise, I'm at a loss.

Here's the procedure code I have so far:


Dim appWord As New Word.Application
Dim docWord As New Word.Document

docWord = appWord.Documents.Open("L:\SWPPP\SWPPPBookMerge.doc")

Further more, I'm hoping to merge data from a table into this document, but I figured opening it would be a good first step.

Thanks in advance!

B. Drake

Is dreamweaver compatible...

I'm lucky to dig out this post. I've the same trouble.
Thank you for reverendleo posting that question. :)

Is dreamweaver compatible...

Import these namespace-
Imports Microsoft.Office
Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop.Word
Imports Microsoft.Office.Tools.Word

you must have to give a refrence to microsoft office library.
steps-
Right click Solution -> Add Refrence -> Go to COM tab -> select Microsoft office Library 11.0 or 10.0 (your Choice).

Hope Your Problem will be solved.










privacy (GDPR)