Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    New Coder
    Join Date
    May 2005
    Location
    The Lone Star State
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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:

    Code:
    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

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    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!
    I am the luckiest man in the world

  • #3
    New Coder
    Join Date
    May 2005
    Location
    The Lone Star State
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    Imports Microsoft.Office.Interop
    I am the luckiest man in the world

  • #5
    New Coder
    Join Date
    May 2005
    Location
    The Lone Star State
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    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
    I am the luckiest man in the world

  • #7
    New Coder
    Join Date
    May 2005
    Location
    The Lone Star State
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Appreciate it sir.

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

    Thanks!

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    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
    I am the luckiest man in the world

  • #9
    New Coder
    Join Date
    May 2005
    Location
    The Lone Star State
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #10
    New Coder
    Join Date
    Sep 2003
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #11
    Regular Coder
    Join Date
    May 2007
    Location
    UK
    Posts
    180
    Thanks
    0
    Thanked 18 Times in 18 Posts
    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.

  • #12
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by reverendleo View Post
    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:

    Code:
    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...

  • #13
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm lucky to dig out this post. I've the same trouble.
    Thank you for reverendleo posting that question.

  • #14
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by sonnyharrison1 View Post
    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.


  •  

    Posting Permissions

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