0

Hi everyone,

I have an interesting situation at hand.
I already succeeded in uploading files (.doc, .docx, etc) to both the database and a folder on the server. I can also download the files to client systems successfully without any issue.

However, my manager wants people to be able to see the content of some of the file on the home page of our website. I've been thinking on how to extract the content of the files (stored in database and server) and then display it on the page.

He says the files can be updated from time to time, thus the display should be the most recent update. This is why I've been thinking of extracting the content of the data already uploaded.

Any ideas.

2
Contributors
5
Replies
7
Views
5 Years
Discussion Span
Last Post by sufyan2011
0

Thanks sufyan but I do not intend to "open" the document, I only want to extract the text in the document.

Yes, extract the text. That's all

0

Yeah right, document open means in memory not document viewer. Hopefully in above link you can see in detail.

0

Thanks sufyan,

I eventually worked around your solution with like this

Imports Microsoft.Office.Interop  'Requires reference to Office.dll 

Partial Class _Default
    Inherits System.Web.UI.Page

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim objWord As Word.ApplicationClass
    Dim strText As String
    objWord = New Word.Application()
    With objWord
      .Visible = False
      .Documents.Open(FileLocation_FileName, , True)
      .WordBasic.EditSelectAll()
      .WordBasic.SetDocumentVar("MyVar", .ActiveDocument.ActiveWindow.Selection.Text)
      strText = .WordBasic.GetDocumentVar("MyVar")
      Label1.Text = InsertNewLineChars(Strings.Left(strText, Len(strText) - 1))
      .Documents.Close(0)
      .Quit()
    End With
    'End Sub

  End Sub

  Private Function InsertNewLineChars(ByVal strText As String) As String
    Dim pos As Integer, l As Integer
    pos = 1
    Do While pos < Len(strText)
      l = Strings.InStr(pos, strText, vbCr)
      If l = 0 Then Exit Do
      strText = Strings.Left(strText, l - 1) & vbCrLf & Mid(strText, l + 1)
      pos = l + 2
    Loop
    Return strText
  End Function
End Class
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.