Click here to Skip to main content
15,886,110 members

Microsoft.Office.Interop.Word without installing MS Office

Muhammed Haris K asked:

Open original thread
Hi,

Web application Microsoft.Office.Interop.Word not working on the server.But it works fine in local machine. The application hosted in arvixe. I want to show a document(which is word, PDFs...etc) in a text box. The working in local machine is smooth but in live it is empty text box.The application developed in .Net.My VB.Net code for this purpose is given below.

VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

       If Not Session("r_id") Is Nothing Then

           iframe.Visible = False
           Text_resume.Visible = False
           Dim resume_name As String = Session("r_id") 'Server.HtmlEncode(Request.QueryString("r_id"))
           Dim filepath As String = resume_name
           Dim fileextention As String = Path.GetExtension(filepath)
           If Not fileextention = ".pdf" Then
               Text_resume.Visible = True
               Dim realpath As String = MapPath("../jobseeker/Resume/" + filepath)
               readFileContent(realpath)
           Else
               Dim realpath As String = "../jobseeker/Resume/" + filepath
               iframe.Visible = True
               iframe.Disabled = True
               iframe.Attributes.Add("src", realpath & "?docId=456#toolbar=0")
           End If

       End If
       lbl_check.Text = _path

   End Sub
   Private Sub readFileContent(ByVal path As String)
       Try
           Dim wordApp As New ApplicationClass()
           Dim file As Object = path
           _path = path
           Dim nullobj As Object = System.Reflection.Missing.Value
           Dim doc As Microsoft.Office.Interop.Word.Document = wordApp.Documents.Open(file, nullobj, nullobj, nullobj, nullobj, nullobj, _
           nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, _
           nullobj, nullobj, nullobj, nullobj)
           doc.ActiveWindow.Selection.WholeStory()
           doc.ActiveWindow.Selection.Copy()
           Dim sFileText As String = doc.Content.Text
           doc.Close(nullobj, nullobj, nullobj)
           wordApp.Quit(nullobj, nullobj, nullobj)
           Text_resume.Text = sFileText.ToString()
       Catch ex As Exception
           'alert.show_mssg(panel_mssg, lbl_mssg, "mssg_fail", "Your enquiries has been inserted successfully")

       End Try
   End Sub


Thanking in Advance.

Muhammed Haris K
Tags: .NET, DLL

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900