Solved

Opening ms. word files

Posted on 2000-05-06
5
147 Views
Last Modified: 2010-04-30
Who can explain me how to open a msword file in my programm, that includes also the text in its word form.



please give me some code.



i have a text field : text1
0
Comment
Question by:markyvt
  • 2
  • 2
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
ID: 2785354
I know of 2 things, but you won't be able to display the formatted text in your text box, you would need richtextbox...

1=Office Automation
 Check Microsoft Word in Project References
 Sub GetWordData
   DIM appWord as Word.Application
   DIM objDocument as Word.Document

   SET appWord = NEW Word.Application
   SET objDocument = appWord.Documents.Open ("C:\Mydoc.Doc")

   text1.Text = objDocument.Range.Text
   objDocument.Close
   SET objDocument = NOTHING
   appWord.Quit
   SET appWord = NOTHING
 End Sub


2=Webbrowser Control (to display Word Document inside of your application)
 Check Microsoft Internet Controls in Project Components
 Add Webbrowser Control to your form (with name "webBrowser")
 Sub OpenDoc(Path as string)
   webBrowser.NavigateTo Path
 End Sub

Hope this helps


0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2785393
even a richtextbox doesnt potentially handle all the formatting of a ms word document.  for this you should save the word file as a temporary text file, and then read that text file into your textbox.

How to translate a word doc to txt file:
http://www.vb-helper.com/Howto/word2txt.zip
0
 
LVL 2

Author Comment

by:markyvt
ID: 2794084
From: AzraSound
 Date: Sunday, May 07 2000 - 10:56AM CEST  
even a richtextbox doesnt potentially handle all the formatting of a ms word document.  for this you should save the word file as a temporary text file, and then read that text file into your textbox.

How to translate a word doc to txt file:
http://www.vb-helper.com/Howto/word2txt.zip

 

Thanks Azrasound but the webbrowser component does enough for me, to bad i could'nt give you also some points.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2794102
sorry i thought you were trying to read the document's text into a textbox
0
 
LVL 2

Author Comment

by:markyvt
ID: 2794246
I was but the other thing worked out better,

sorry,.

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question